add latex config using vimtex and change neotree to auto chdir work dir
This commit is contained in:
parent
e559ba5a58
commit
2e06e0d601
1
init.lua
1
init.lua
@ -10,6 +10,7 @@ require("plugin-config/treesitter")
|
||||
require("plugin-config/telescope")
|
||||
require("plugin-config/whichkey")
|
||||
require("plugin-config/comment")
|
||||
require("plugin-config/vimtex")
|
||||
require("plugin-config/mason")
|
||||
require("plugin-config/lua_line")
|
||||
require("plugin-config/notify")
|
||||
|
@ -27,6 +27,12 @@ function set_colorscheme()
|
||||
end
|
||||
end
|
||||
|
||||
function auto_chdir()
|
||||
local filename = vim.fn.expand("%:p")
|
||||
local directory = vim.fn.fnamemodify(filename, ":h")
|
||||
vim.cmd("cd " .. directory)
|
||||
end
|
||||
|
||||
local autoCommands = {
|
||||
-- other autocommands
|
||||
open_folds = {
|
||||
@ -36,7 +42,7 @@ local autoCommands = {
|
||||
{ "VimEnter", "*", "lua set_colorscheme()" },
|
||||
},
|
||||
auto_change_directory = {
|
||||
{ "BufEnter", "*", "lcd %:p:h" },
|
||||
{ "BufEnter", "*", "lua auto_chdir()" },
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -100,6 +100,25 @@ wk.register({
|
||||
},
|
||||
})
|
||||
|
||||
-- 定义开关quickfix窗口的函数
|
||||
|
||||
local function toggle_quickfix()
|
||||
-- 获取所有窗口的信息
|
||||
local wininfo = vim.fn.getwininfo()
|
||||
-- 遍历所有窗口
|
||||
for _, win in pairs(wininfo) do
|
||||
-- 如果这个窗口是 quickfix 窗口
|
||||
if win.quickfix == 1 then
|
||||
-- 关闭 quickfix 窗口
|
||||
vim.cmd("cclose")
|
||||
-- 返回,不再继续查找
|
||||
return
|
||||
end
|
||||
end
|
||||
-- 如果没有找到 quickfix 窗口,就打开一个
|
||||
vim.cmd("copen")
|
||||
end
|
||||
|
||||
-- Bufferline and buffer related
|
||||
wk.register({
|
||||
["<Leader>b"] = {
|
||||
@ -110,7 +129,12 @@ wk.register({
|
||||
n = { ":ls<CR>", "Buffer numbers" },
|
||||
c = { ":noh<CR>", "Cancel highlight" },
|
||||
C = { ":call setqflist([], 'r')<CR>", "Clear quickfix" },
|
||||
q = { ":copen<CR>", "Open quickfix" },
|
||||
q = {
|
||||
function()
|
||||
toggle_quickfix()
|
||||
end,
|
||||
"Toggle quickfix",
|
||||
},
|
||||
s = { ":Telescope current_buffer_fuzzy_find<CR>", "Searching in buffer" },
|
||||
},
|
||||
})
|
||||
|
@ -21,6 +21,7 @@ cmp.setup({
|
||||
sources = cmp.config.sources({
|
||||
{ name = "orgmode" },
|
||||
{ name = "nvim_lsp" },
|
||||
{ name = "omni" },
|
||||
-- For vsnip users.
|
||||
-- { name = "vsnip" },
|
||||
-- For luasnip users.
|
||||
|
1
lua/lsp/config/texlab.lua
Normal file
1
lua/lsp/config/texlab.lua
Normal file
@ -0,0 +1 @@
|
||||
return require("lsp.config.basic_config")
|
@ -8,7 +8,7 @@ local servers = {
|
||||
lua_ls = require("lsp.config.lua"), -- lua/lsp/config/lua.lua
|
||||
clangd = require("lsp.config.clangd"),
|
||||
gopls = require("lsp.config.gopls"),
|
||||
eslint = require("lsp.config.eslint"),
|
||||
-- eslint = require("lsp.config.eslint"),
|
||||
-- r_language_server = require("lsp.config.r"),
|
||||
-- csharp_ls = require("lsp.config.csharp"),
|
||||
omnisharp = require("lsp.config.csharp"),
|
||||
@ -16,12 +16,13 @@ local servers = {
|
||||
pyright = require("lsp.config.pyright"),
|
||||
marksman = require("lsp.config.marksman"),
|
||||
pylsp = require("lsp.config.pylsp"),
|
||||
volar = require("lsp.config.vue"),
|
||||
-- texlab = require("lsp.config.texlab"),
|
||||
-- volar = require("lsp.config.vue"),
|
||||
-- html = require("lsp.config.html"),
|
||||
-- cssls = require("lsp.config.css"),
|
||||
-- emmet_ls = require("lsp.config.emmet"),
|
||||
-- jsonls = require("lsp.config.json"),
|
||||
-- tsserver = require("lsp.config.ts"),
|
||||
tsserver = require("lsp.config.ts"),
|
||||
-- rust_analyzer = require("lsp.config.rust"),
|
||||
-- yamlls = require("lsp.config.yamlls"),
|
||||
-- remark_ls = require("lsp.config.markdown"),
|
||||
|
@ -15,12 +15,12 @@ require("null-ls").setup({
|
||||
require("null-ls").builtins.formatting.stylua,
|
||||
require("null-ls").builtins.formatting.styler,
|
||||
require("null-ls").builtins.formatting.clang_format.with({
|
||||
disabled_filetypes = { "cs" },
|
||||
disabled_filetypes = { "cs", "js" },
|
||||
}),
|
||||
require("null-ls").builtins.formatting.csharpier,
|
||||
require("null-ls").builtins.formatting.gofmt,
|
||||
require("null-ls").builtins.formatting.black,
|
||||
require("null-ls").builtins.formatting.eslint_d,
|
||||
require("null-ls").builtins.formatting.prettier,
|
||||
require("null-ls").builtins.formatting.jq,
|
||||
},
|
||||
-- you can reuse a shared lspconfig on_attach callback here
|
||||
|
@ -2,5 +2,7 @@ require("neo-tree").setup({
|
||||
window = {
|
||||
width = "25%", -- Width of the Neo-tree window
|
||||
},
|
||||
update_cwd = true,
|
||||
filesystem = {
|
||||
bind_to_cwd = true,
|
||||
},
|
||||
})
|
||||
|
@ -24,13 +24,16 @@ require("nvim-treesitter.configs").setup({
|
||||
-- list of language that will be disabled
|
||||
-- disable = { "c", "rust" },
|
||||
-- Or use a function for more flexibility, e.g. to disable slow treesitter highlight for large files
|
||||
disable = function(lang, buf)
|
||||
local max_filesize = 100 * 1024 -- 100 KB
|
||||
local ok, stats = pcall(vim.loop.fs_stat, vim.api.nvim_buf_get_name(buf))
|
||||
if ok and stats and stats.size > max_filesize then
|
||||
return true
|
||||
end
|
||||
end,
|
||||
disable = {
|
||||
"latex",
|
||||
function(lang, buf)
|
||||
local max_filesize = 100 * 1024 -- 100 KB
|
||||
local ok, stats = pcall(vim.loop.fs_stat, vim.api.nvim_buf_get_name(buf))
|
||||
if ok and stats and stats.size > max_filesize then
|
||||
return true
|
||||
end
|
||||
end,
|
||||
},
|
||||
|
||||
-- Setting this to true will run `:h syntax` and tree-sitter at the same time.
|
||||
-- Set this to `true` if you depend on 'syntax' being enabled (like for indentation).
|
||||
|
17
lua/plugin-config/vimtex.lua
Normal file
17
lua/plugin-config/vimtex.lua
Normal file
@ -0,0 +1,17 @@
|
||||
-- This is necessary for VimTeX to load properly. The "indent" is optional.
|
||||
-- Note that most plugin managers will do this automatically.
|
||||
vim.cmd("filetype plugin indent on")
|
||||
-- This enables Vim's and Neovim's syntax-related features. Without this, some
|
||||
-- VimTeX features will not work (see ":help vimtex-requirements" for more info).
|
||||
vim.cmd("syntax enable")
|
||||
|
||||
-- Viewer options: One may configure the viewer either by specifying a built-in
|
||||
-- viewer method:
|
||||
vim.g.vimtex_view_method = "skim"
|
||||
-- vim.g.vimtex_view_general_options = "--unique file:@pdf\\#src:@line@tex"
|
||||
|
||||
vim.g.vimtex_complete_close_braces = 1
|
||||
vim.g.vimtex_syntax_enabled = 1
|
||||
vim.g.vimtex_compiler_latexmk_engines = {
|
||||
["_"] = "-xelatex",
|
||||
}
|
@ -60,6 +60,9 @@ return require("packer").startup(function()
|
||||
},
|
||||
})
|
||||
|
||||
----------------latex------------------
|
||||
use("lervag/vimtex")
|
||||
|
||||
-- vim dashboard
|
||||
-- vim 开始界面
|
||||
use({
|
||||
@ -186,6 +189,7 @@ return require("packer").startup(function()
|
||||
use("hrsh7th/cmp-nvim-lsp") -- { name = nvim_lsp }
|
||||
use("hrsh7th/cmp-buffer") -- { name = 'buffer' },
|
||||
use("hrsh7th/cmp-path") -- { name = 'path' }
|
||||
use("hrsh7th/cmp-omni") -- { name = 'omni' }
|
||||
use("hrsh7th/cmp-cmdline") -- { name = 'cmdline' }
|
||||
use("hrsh7th/cmp-nvim-lsp-signature-help") -- { name = 'nvim_lsp_signature_help' }
|
||||
-- 常见编程语言代码段
|
||||
|
Loading…
Reference in New Issue
Block a user