From 1f3896974d13ebb83df197bcb11039a7e58ff763 Mon Sep 17 00:00:00 2001 From: Young Xu Date: Sun, 26 Feb 2023 21:29:03 +0800 Subject: [PATCH] fix: golang lsp action --- README.md | 2 + ftplugin/javascript.vim | 1 + ftplugin/markdown.vim | 51 +++++ ftplugin/mysql.vim | 1 + ftplugin/proto.vim | 105 ++++++++++ ftplugin/python.vim | 1 + ftplugin/sql.vim | 1 + ftplugin/typescript.vim | 1 + ftplugin/vue.vim | 4 + init.lua | 32 +-- lua/core/g.lua | 52 +++++ lua/core/keymapping.lua | 137 ++++++------ lua/core/option.lua | 2 - lua/core/theme.lua | 2 +- lua/lsp/clang.lua | 19 ++ lua/lsp/go.lua | 107 +++++----- lua/lsp/protocol.lua | 2 +- lua/plugins/auto-do.lua | 7 + lua/plugins/auto-save.lua | 3 - lua/plugins/bufferline.lua | 30 +-- lua/plugins/debug.lua | 7 + lua/plugins/file-tree.lua | 53 ++--- lua/plugins/golang.lua | 10 +- lua/plugins/indent_blackline.lua | 8 +- lua/plugins/leap.lua | 14 +- lua/plugins/legendary.lua | 9 + lua/plugins/line-numbers.lua | 1 - lua/plugins/lspsaga.lua | 16 +- lua/plugins/lualine.lua | 76 +++---- lua/plugins/mason.lua | 59 +++--- lua/plugins/null-ls.lua | 42 +--- lua/plugins/peaceful.lua | 12 ++ lua/plugins/telescope.lua | 48 ++++- lua/plugins/terminal.lua | 1 - lua/plugins/treesitter.lua | 19 +- lua/plugins/trouble.lua | 1 - lua/plugins/wilder.lua | 52 +++++ lua/setup.lua | 345 ++++++++++++++++++------------- 38 files changed, 877 insertions(+), 456 deletions(-) create mode 100644 ftplugin/javascript.vim create mode 100644 ftplugin/markdown.vim create mode 100644 ftplugin/mysql.vim create mode 100644 ftplugin/proto.vim create mode 100644 ftplugin/python.vim create mode 100644 ftplugin/sql.vim create mode 100644 ftplugin/typescript.vim create mode 100644 ftplugin/vue.vim create mode 100644 lua/core/g.lua create mode 100644 lua/lsp/clang.lua create mode 100644 lua/plugins/auto-do.lua delete mode 100644 lua/plugins/auto-save.lua create mode 100644 lua/plugins/debug.lua create mode 100644 lua/plugins/legendary.lua delete mode 100644 lua/plugins/line-numbers.lua create mode 100644 lua/plugins/peaceful.lua delete mode 100644 lua/plugins/terminal.lua delete mode 100644 lua/plugins/trouble.lua create mode 100644 lua/plugins/wilder.lua diff --git a/README.md b/README.md index ed5d104..fb559c3 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,8 @@ go install github.com/jesseduffield/lazygit@latest npm install eslint --global npm install -g typescript typescript-language-server npm install -g @volar/vue-language-server +npm install -g eslint_d +go install github.com/yoheimuta/protolint/cmd/protolint@latest ``` ### 记忆项 diff --git a/ftplugin/javascript.vim b/ftplugin/javascript.vim new file mode 100644 index 0000000..f9ef053 --- /dev/null +++ b/ftplugin/javascript.vim @@ -0,0 +1 @@ +vnoremap D :call SurroundVaddPairs("/** ", " */") diff --git a/ftplugin/markdown.vim b/ftplugin/markdown.vim new file mode 100644 index 0000000..c1d00ec --- /dev/null +++ b/ftplugin/markdown.vim @@ -0,0 +1,51 @@ +hi MDTask ctermfg=1 +hi MDDoneText ctermfg=37 cterm=italic,strikethrough +hi MDTodoText cterm=NONE +hi MDDoneDate cterm=strikethrough ctermfg=71 +hi MDTodoDate ctermfg=71 +hi Deadline ctermfg=162 cterm=bold,underline +hi NearDeadline ctermfg=178 cterm=bold +au FileType markdown syn match markdownError "\w\@<=\w\@=" +au FileType markdown syn match MDDoneDate /[SD]:\d\{4\}\([\/-]\d\d\)\{2\}/ contained +au FileType markdown syn match MDTodoDate /[SD]:\d\{4\}\([\/-]\d\d\)\{2\}/ contained +au FileType markdown syn match MDDoneText /- \[x\] \zs.*/ contains=MDDoneDate contained +au FileType markdown syn match MDTodoText /- \[ \] \zs.*/ contains=MDTodoDate contained +au FileType markdown syn match MDTask /- \[\(x\| \)\] .*/ contains=MDDoneText,MDTodoText +au FileType markdown call matchadd('Deadline', 'D:'.strftime("%Y-%m-%d")) +au FileType markdown call matchadd('NearDeadline', 'D:'.strftime("%Y-%m-%d", localtime() + 3600 * 24)) +au FileType markdown call matchadd('NearDeadline', 'D:'.strftime("%Y-%m-%d", localtime() + 3600 * 48)) + +let b:md_block = '```' +setlocal shiftwidth=2 +setlocal softtabstop=2 +setlocal tabstop=2 +nnoremap :call toggleTodoStatus() +nnoremap <2-LeftMouse> :call toggleTodoStatus():w<2-LeftMouse> +vnoremap B :call SurroundVaddPairs("**", "**") +vnoremap I :call SurroundVaddPairs("*", "*") +vnoremap T :call SurroundVaddPairs("- [ ] ", "") +vnoremap ` :call SurroundVaddPairs("`", "`") +vnoremap C :call SurroundVaddPairs("```plaintext", "```") + +fun! s:toggleTodoStatus() + let line = getline('.') + if line =~ glob2regpat('*- \[ \]*') + call setline('.', substitute(line, '\[ \]', '[x]', '')) + elseif line =~ glob2regpat('*- \[x\]*') + call setline('.', substitute(line, '\[x\]', '[ ]', '')) + endif +endf + +nnoremap :call toggleMPTheme() +inoremap :call toggleMPTheme() +fun! s:toggleMPTheme() + if g:mkdp_theme == 'dark' + let g:mkdp_theme = 'light' + else + let g:mkdp_theme = 'dark' + endif + + exec 'MarkdownPreviewStop' + sleep 1 + exec 'MarkdownPreview' +endf diff --git a/ftplugin/mysql.vim b/ftplugin/mysql.vim new file mode 100644 index 0000000..e37eb4b --- /dev/null +++ b/ftplugin/mysql.vim @@ -0,0 +1 @@ +let g:omni_sql_no_default_maps = 1 diff --git a/ftplugin/proto.vim b/ftplugin/proto.vim new file mode 100644 index 0000000..bdc60ce --- /dev/null +++ b/ftplugin/proto.vim @@ -0,0 +1,105 @@ +" Protocol Buffers - Google's data interchange format +" Copyright 2008 Google Inc. All rights reserved. +" https://developers.google.com/protocol-buffers/ +" +" Redistribution and use in source and binary forms, with or without +" modification, are permitted provided that the following conditions are +" met: +" +" * Redistributions of source code must retain the above copyright +" notice, this list of conditions and the following disclaimer. +" * Redistributions in binary form must reproduce the above +" copyright notice, this list of conditions and the following disclaimer +" in the documentation and/or other materials provided with the +" distribution. +" * Neither the name of Google Inc. nor the names of its +" contributors may be used to endorse or promote products derived from +" this software without specific prior written permission. +" +" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +" A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +" OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +" OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +" This is the Vim syntax file for Google Protocol Buffers. +" +" Usage: +" +" 1. cp proto.vim ~/.vim/syntax/ +" 2. Add the following to ~/.vimrc: +" +" augroup filetype +" au! BufRead,BufNewFile *.proto setfiletype proto +" augroup end +" +" Or just create a new file called ~/.vim/ftdetect/proto.vim with the +" previous lines on it. + +if version < 600 + syntax clear +elseif exists("b:current_syntax") + finish +endif + +syn case match + +syn keyword pbTodo contained TODO FIXME XXX +syn cluster pbCommentGrp contains=pbTodo + +syn keyword pbSyntax syntax import option +syn keyword pbStructure package message group oneof +syn keyword pbRepeat optional required repeated +syn keyword pbDefault default +syn keyword pbExtend extend extensions to max reserved +syn keyword pbRPC service rpc returns + +syn keyword pbType int32 int64 uint32 uint64 sint32 sint64 +syn keyword pbType fixed32 fixed64 sfixed32 sfixed64 +syn keyword pbType float double bool string bytes +syn keyword pbTypedef enum +syn keyword pbBool true false + +syn match pbInt /-\?\<\d\+\>/ +syn match pbInt /\<0[xX]\x+\>/ +syn match pbFloat /\<-\?\d*\(\.\d*\)\?/ +syn region pbComment start="\/\*" end="\*\/" contains=@pbCommentGrp,@Spell +syn region pbComment start="//" skip="\\$" end="$" keepend contains=@pbCommentGrp,@Spell +syn region pbString start=/"/ skip=/\\./ end=/"/ contains=@Spell +syn region pbString start=/'/ skip=/\\./ end=/'/ contains=@Spell + +if version >= 508 || !exists("did_proto_syn_inits") + if version < 508 + let did_proto_syn_inits = 1 + command -nargs=+ HiLink hi link + else + command -nargs=+ HiLink hi def link + endif + + HiLink pbTodo Todo + + HiLink pbSyntax Include + HiLink pbStructure Structure + HiLink pbRepeat Repeat + HiLink pbDefault Keyword + HiLink pbExtend Keyword + HiLink pbRPC Keyword + HiLink pbType Type + HiLink pbTypedef Typedef + HiLink pbBool Boolean + + HiLink pbInt Number + HiLink pbFloat Float + HiLink pbComment Comment + HiLink pbString String + + delcommand HiLink +endif + +let b:current_syntax = "proto" diff --git a/ftplugin/python.vim b/ftplugin/python.vim new file mode 100644 index 0000000..f9ef053 --- /dev/null +++ b/ftplugin/python.vim @@ -0,0 +1 @@ +vnoremap D :call SurroundVaddPairs("/** ", " */") diff --git a/ftplugin/sql.vim b/ftplugin/sql.vim new file mode 100644 index 0000000..e37eb4b --- /dev/null +++ b/ftplugin/sql.vim @@ -0,0 +1 @@ +let g:omni_sql_no_default_maps = 1 diff --git a/ftplugin/typescript.vim b/ftplugin/typescript.vim new file mode 100644 index 0000000..f9ef053 --- /dev/null +++ b/ftplugin/typescript.vim @@ -0,0 +1 @@ +vnoremap D :call SurroundVaddPairs("/** ", " */") diff --git a/ftplugin/vue.vim b/ftplugin/vue.vim new file mode 100644 index 0000000..6be9c07 --- /dev/null +++ b/ftplugin/vue.vim @@ -0,0 +1,4 @@ +augroup vue + au! + autocmd BufWritePre *.vue :call CocAction('format') +augroup END diff --git a/init.lua b/init.lua index e621335..645af1a 100644 --- a/init.lua +++ b/init.lua @@ -1,18 +1,16 @@ -require("impatient") -- start quickly require("setup") +require("core.g") require("core.option") -- 加载插件配置文件 -- 文件树 require("plugins.file-tree") --- 行号模式切换 -require("plugins.line-numbers") --- 模糊搜索 -require("plugins.telescope") +-- 默认配置 +require("plugins.peaceful") +-- debug 配置 +require("plugins.debug") -- mason管理 require("plugins.mason") --- 终端管理 -require("plugins.terminal") -- bufferline require("plugins.bufferline") -- 空白缩进 @@ -20,23 +18,24 @@ require("plugins.indent_blackline") -- 底部状态 require("plugins.lualine") -- 自动保存 -require("plugins.auto-save") +require("plugins.auto-do") -- 通知 require("plugins.notify") -- 格式化 require("plugins.null-ls") --- 错误列表 -require("plugins.trouble") -- git require("plugins.gitsigns") +-- 文件搜索 +require("plugins.telescope") -- 快速跳转 require("plugins.leap") -- 代码高亮配置 require("plugins.treesitter") --- lspsaga -require("plugins.lspsaga") --- golang lsp -require("plugins.golang") +-- wilder配置 +require("plugins.wilder") +-- 自定义快捷键配置 +require("plugins.legendary") +-- lsp 配置 require("lsp.init") require("lsp.bash") require("lsp.docker") @@ -45,6 +44,11 @@ require("lsp.go") require("lsp.lua") require("lsp.protocol") require("lsp.volar") +require("lsp.clang") +-- lspsaga +require("plugins.lspsaga") +-- golang lsp +require("plugins.golang") -- 载入主题 require("core.theme") diff --git a/lua/core/g.lua b/lua/core/g.lua new file mode 100644 index 0000000..b2053d1 --- /dev/null +++ b/lua/core/g.lua @@ -0,0 +1,52 @@ +local G = {} + +G.g = vim.g +G.b = vim.b +G.o = vim.o +G.v = vim.v +G.fn = vim.fn +G.api = vim.api +G.opt = vim.opt + +function G.map(maps) + for _, map in pairs(maps) do + G.api.nvim_set_keymap(map[1], map[2], map[3], map[4]) + end +end + +function G.hi(hls) + local colormode = G.o.termguicolors and "" or "cterm" + for group, color in pairs(hls) do + local opt = {} + if color.fg then + opt[colormode .. "fg"] = color.fg + end + if color.bg then + opt[colormode .. "bg"] = color.bg + end + if color.italic then + opt.italic = true + end + if color.bold then + opt.bold = true + end + if color.underline then + opt.underline = true + end + G.api.nvim_set_hl(0, group, opt) + end +end + +function G.cmd(cmd) + G.api.nvim_command(cmd) +end + +function G.exec(c) + G.api.nvim_exec(c) +end + +function G.eval(c) + return G.api.nvim_eval(c) +end + +return G diff --git a/lua/core/keymapping.lua b/lua/core/keymapping.lua index a6781b2..64976e4 100644 --- a/lua/core/keymapping.lua +++ b/lua/core/keymapping.lua @@ -7,15 +7,15 @@ local noreopt = { noremap = true, silent = true } -- save map.set({ "n", "i" }, "", "w", noreopt) -- format -map.set({ "n", "i" }, "=", "lua vim.lsp.buf.format()", noreopt) +map.set({ "n", "v", "x" }, "=", "lua vim.lsp.buf.format()", noreopt) -- fine cmdline map.set("n", ":", "FineCmdline", noreopt) -- telescope -map.set("n", "ff", "Telescope find_files") -- find files within current working directory, respects .gitignore -map.set("n", "fs", "Telescope live_grep") -- find string in current working directory as you type -map.set("n", "fc", "Telescope grep_string") -- find string under cursor in current working directory -map.set("n", "fb", "Telescope buffers") -- list open buffers in current neovim instance -map.set("n", "fh", "Telescope help_tags") -- list available help tags +map.set("n", "ff", "Telescope find_files") -- find files within current working directory, respects .gitignore +map.set("n", "fs", "Telescope live_grep") -- find string in current working directory as you type +map.set("n", "fc", "Telescope grep_string") -- find string under cursor in current working directory +map.set("n", "fb", "Telescope buffers") -- list open buffers in current neovim instance +map.set("n", "fh", "Telescope help_tags") -- list available help tags map.set("n", "lds", "Telescope lsp_document_symbols") -- list all functions/structs/classes/modules in the current buffer -- 重置窗口大小 map.set("n", "", ":resize -2", noreopt) @@ -30,7 +30,10 @@ map.set("n", "", "l", noreopt) -- 分屏 map.set("n", "sv", ":vsp", noreopt) map.set("n", "sh", ":sp", noreopt) --- 代码块移动 +-- 代码块选择和移动 +map.set({ "n", "v" }, "L", "$", noreopt) -- 快速行尾 +map.set({ "n", "v" }, "H", "^", noreopt) -- 快速行首 +map.set({ "n", "v", "i" }, "", "ggG", noreopt) -- 全选 map.set("n", "", ":m .+1==gi", noreopt) map.set("n", "", ":m .-2==gi", noreopt) map.set("v", "<", "", noreopt) map.set("n", "mp", ":MarkdownPreviewToggle", noreopt) -- lspsage function _G.set_lspsage_keymaps() - local keymap = vim.keymap.set - keymap("n", "cf", "Lspsaga lsp_finder") + local keymap = vim.keymap.set + keymap("n", "cf", "Lspsaga lsp_finder") - -- Code action - keymap({ "n", "v" }, "ca", "Lspsaga code_action") + -- Code action + keymap({ "n", "v" }, "ca", "Lspsaga code_action") - -- Rename all occurrences of the hovered word for the entire file - keymap("n", "rn", "Lspsaga rename") + -- Rename all occurrences of the hovered word for the entire file + keymap("n", "rn", "Lspsaga rename") - -- Rename all occurrences of the hovered word for the selected files - keymap("n", "rn", "Lspsaga rename ++project") + -- Rename all occurrences of the hovered word for the selected files + keymap("n", "rn", "Lspsaga rename ++project") - -- Peek definition - -- You can edit the file containing the definition in the floating window - -- It also supports open/vsplit/etc operations, do refer to "definition_action_keys" - -- It also supports tagstack - -- Use to jump back - keymap("n", "gd", "Lspsaga peek_definition") + -- Peek definition + -- You can edit the file containing the definition in the floating window + -- It also supports open/vsplit/etc operations, do refer to "definition_action_keys" + -- It also supports tagstack + -- Use to jump back + keymap("n", "gd", "Lspsaga peek_definition") - -- Peek type definition - -- You can edit the file containing the type definition in the floating window - -- It also supports open/vsplit/etc operations, do refer to "definition_action_keys" - -- It also supports tagstack - -- Use to jump back - keymap("n", "gt", "Lspsaga peek_type_definition") + -- Peek type definition + -- You can edit the file containing the type definition in the floating window + -- It also supports open/vsplit/etc operations, do refer to "definition_action_keys" + -- It also supports tagstack + -- Use to jump back + keymap("n", "gt", "Lspsaga peek_type_definition") - -- Show line diagnostics - -- You can pass argument ++unfocus to - -- unfocus the show_line_diagnostics floating window - keymap("n", "sl", "Lspsaga show_line_diagnostics") + -- Show line diagnostics + -- You can pass argument ++unfocus to + -- unfocus the show_line_diagnostics floating window + keymap("n", "sl", "Lspsaga show_line_diagnostics") - -- Show cursor diagnostics - -- Like show_line_diagnostics, it supports passing the ++unfocus argument - keymap("n", "sc", "Lspsaga show_cursor_diagnostics") + -- Show cursor diagnostics + -- Like show_line_diagnostics, it supports passing the ++unfocus argument + keymap("n", "sc", "Lspsaga show_cursor_diagnostics") - -- Show buffer diagnostics - keymap("n", "sb", "Lspsaga show_buf_diagnostics") + -- Show buffer diagnostics + keymap("n", "sb", "Lspsaga show_buf_diagnostics") - -- Diagnostic jump - -- You can use to jump back to your previous location - keymap("n", "[e", "Lspsaga diagnostic_jump_prev") - keymap("n", "]e", "Lspsaga diagnostic_jump_next") + -- Diagnostic jump + -- You can use to jump back to your previous location + keymap("n", "[e", "Lspsaga diagnostic_jump_prev") + keymap("n", "]e", "Lspsaga diagnostic_jump_next") - -- Diagnostic jump with filters such as only jumping to an error - keymap("n", "[E", function() - require("lspsaga.diagnostic"):goto_prev({ severity = vim.diagnostic.severity.ERROR }) - end) - keymap("n", "]E", function() - require("lspsaga.diagnostic"):goto_next({ severity = vim.diagnostic.severity.ERROR }) - end) + -- Diagnostic jump with filters such as only jumping to an error + keymap("n", "[E", function() + require("lspsaga.diagnostic"):goto_prev({ severity = vim.diagnostic.severity.ERROR }) + end) + keymap("n", "]E", function() + require("lspsaga.diagnostic"):goto_next({ severity = vim.diagnostic.severity.ERROR }) + end) - -- Toggle outline - keymap("n", "o", "Lspsaga outline") + -- Toggle outline + keymap("n", "o", "Lspsaga outline") - -- Hover Doc - -- If there is no hover doc, - -- there will be a notification stating that - -- there is no information available. - -- To disable it just use ":Lspsaga hover_doc ++quiet" - -- Pressing the key twice will enter the hover window - keymap("n", "K", "Lspsaga hover_doc") + -- Hover Doc + -- If there is no hover doc, + -- there will be a notification stating that + -- there is no information available. + -- To disable it just use ":Lspsaga hover_doc ++quiet" + -- Pressing the key twice will enter the hover window + keymap("n", "K", "Lspsaga hover_doc") - -- If you want to keep the hover window in the top right hand corner, - -- you can pass the ++keep argument - -- Note that if you use hover with ++keep, pressing this key again will - -- close the hover window. If you want to jump to the hover window - -- you should use the wincmd command "w" - keymap("n", "K", "Lspsaga hover_doc ++keep") + -- If you want to keep the hover window in the top right hand corner, + -- you can pass the ++keep argument + -- Note that if you use hover with ++keep, pressing this key again will + -- close the hover window. If you want to jump to the hover window + -- you should use the wincmd command "w" + -- keymap("n", "K", "Lspsaga hover_doc ++keep") - -- Call hierarchy - keymap("n", "ci", "Lspsaga incoming_calls") - keymap("n", "co", "Lspsaga outgoing_calls") + -- Call hierarchy + keymap("n", "ci", "Lspsaga incoming_calls") + keymap("n", "co", "Lspsaga outgoing_calls") - -- Floating terminal - keymap({ "n", "t" }, "", "Lspsaga term_toggle") + -- Floating terminal + keymap({ "n", "t" }, "", "Lspsaga term_toggle") end vim.cmd("lua set_lspsage_keymaps()") diff --git a/lua/core/option.lua b/lua/core/option.lua index 5740a25..8a8125a 100644 --- a/lua/core/option.lua +++ b/lua/core/option.lua @@ -73,11 +73,9 @@ vim.opt.backup = false vim.opt.swapfile = false vim.opt.writebackup = false vim.opt.undofile = true -vim.opt.undodir = os.getenv("HOME") .. "/.vim/undodir" -- 开启 Folding vim.wo.foldmethod = "expr" vim.wo.foldexpr = "nvim_treesitter#foldexpr()" -- 默认不要折叠 -- https://stackoverflow.com/questions/8316139/how-to-set-the-default-to-unfolded-when-you-open-a-file vim.wo.foldlevel = 99 - diff --git a/lua/core/theme.lua b/lua/core/theme.lua index 4372c57..6106172 100644 --- a/lua/core/theme.lua +++ b/lua/core/theme.lua @@ -1 +1 @@ -vim.cmd[[colorscheme tokyonight-storm]] +vim.cmd([[colorscheme tokyonight-storm]]) diff --git a/lua/lsp/clang.lua b/lua/lsp/clang.lua new file mode 100644 index 0000000..9a4dfdd --- /dev/null +++ b/lua/lsp/clang.lua @@ -0,0 +1,19 @@ +local lsp_status = require("lsp-status") +lsp_status.register_progress() +lsp_status.config({ + indicator_errors = "❌", + indicator_warnings = "⚠️ ", + indicator_info = "ℹ️ ", + -- https://emojipedia.org/tips/ + indicator_hint = "💡", + indicator_ok = "✅", +}) + +require("lspconfig").clangd.setup({ + filetypes = { "c", "cpp", "objc", "objcpp", "cuda" }, + handlers = lsp_status.extensions.clangd.setup(), + init_options = { + clangdFileStatus = true, + }, + capabilities = lsp_status.capabilities, +}) diff --git a/lua/lsp/go.lua b/lua/lsp/go.lua index 47f1130..8232503 100644 --- a/lua/lsp/go.lua +++ b/lua/lsp/go.lua @@ -1,69 +1,74 @@ local has_words_before = function() - local line, col = unpack(vim.api.nvim_win_get_cursor(0)) - return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil + local line, col = unpack(vim.api.nvim_win_get_cursor(0)) + return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil end local feedkey = function(key, mode) - vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(key, true, true, true), mode, true) + vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(key, true, true, true), mode, true) end local cmp = require("cmp") cmp.setup({ - snippet = { - expand = function(args) - vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users. - end, - }, - mapping = { - [""] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. - [""] = cmp.mapping(function(fallback) - if cmp.visible() then - cmp.select_next_item() - elseif vim.fn["vsnip#available"](1) == 1 then - feedkey("(vsnip-expand-or-jump)", "") - elseif has_words_before() then - cmp.complete() - else - fallback() -- The fallback function sends a already mapped key. In this case, it's probably ``. - end - end, { "i", "s" }), - [""] = cmp.mapping(function() - if cmp.visible() then - cmp.select_prev_item() - elseif vim.fn["vsnip#jumpable"](-1) == 1 then - feedkey("(vsnip-jump-prev)", "") - end - end, { "i", "s" }), - }, - sources = cmp.config.sources({ - { name = "nvim_lsp" }, - { name = "vsnip" }, -- For vsnip users. - }, { - { name = "buffer" }, - }), + snippet = { + expand = function(args) + vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users. + end, + }, + mapping = { + [""] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. + [""] = cmp.mapping(function(fallback) + if cmp.visible() then + cmp.select_next_item() + elseif vim.fn["vsnip#available"](1) == 1 then + feedkey("(vsnip-expand-or-jump)", "") + elseif has_words_before() then + cmp.complete() + else + fallback() -- The fallback function sends a already mapped key. In this case, it's probably ``. + end + end, { "i", "s" }), + [""] = cmp.mapping(function() + if cmp.visible() then + cmp.select_prev_item() + elseif vim.fn["vsnip#jumpable"](-1) == 1 then + feedkey("(vsnip-jump-prev)", "") + end + end, { "i", "s" }), + }, + sources = cmp.config.sources({ + { name = "nvim_lsp" }, + { name = "vsnip" }, -- For vsnip users. + }, { + { name = "buffer" }, + }), }) local capabilities = require("cmp_nvim_lsp").default_capabilities() --nvim-cmp require("lspconfig")["golangci_lint_ls"].setup({ - on_attach = common_lsp_on_attach, - flags = common_lsp_flags, + on_attach = common_lsp_on_attach, + flags = common_lsp_flags, }) +util = require("lspconfig/util") require("lspconfig")["gopls"].setup({ - cmd = { "gopls" }, - on_attach = common_lsp_on_attach, - flags = common_lsp_flags, - capabilities = capabilities, - settings = { - gopls = { - experimentalPostfixCompletions = true, - analyses = { - unusedparams = true, - shadow = true, - }, - }, - }, - init_options = { usePlaceholders = true }, + cmd = { "gopls" }, + filetypes = { "go", "gomod" }, + root_dir = util.root_pattern("go.work", "go.mod", ".git"), + on_attach = common_lsp_on_attach, + flags = common_lsp_flags, + capabilities = capabilities, + settings = { + gopls = { + experimentalPostfixCompletions = true, + analyses = { + unusedparams = true, + shadow = true, + }, + staticcheck = true, + }, + }, + init_options = { usePlaceholders = true }, }) + diff --git a/lua/lsp/protocol.lua b/lua/lsp/protocol.lua index bee4700..0ca66d4 100644 --- a/lua/lsp/protocol.lua +++ b/lua/lsp/protocol.lua @@ -3,7 +3,7 @@ local capabilities = vim.lsp.protocol.make_client_capabilities() capabilities.textDocument.completion.completionItem.snippetSupport = true require("lspconfig").jsonls.setup({ - capabilities = capabilities, + capabilities = capabilities, }) require("lspconfig").taplo.setup({}) diff --git a/lua/plugins/auto-do.lua b/lua/plugins/auto-do.lua new file mode 100644 index 0000000..610c188 --- /dev/null +++ b/lua/plugins/auto-do.lua @@ -0,0 +1,7 @@ +require("auto-save").setup({ + trigger_events = { "InsertLeave", "BufLeave", "BufWinLeave" }, +}) +require("nvim-autopairs").setup({}) +require("nvim-ts-autotag").setup({}) +require("unimpaired").setup({}) +require("luasnip.loaders.from_vscode").lazy_load() diff --git a/lua/plugins/auto-save.lua b/lua/plugins/auto-save.lua deleted file mode 100644 index 87388d5..0000000 --- a/lua/plugins/auto-save.lua +++ /dev/null @@ -1,3 +0,0 @@ -require("auto-save").setup { - trigger_events = {"InsertLeave", "BufLeave", "BufWinLeave"}, -} diff --git a/lua/plugins/bufferline.lua b/lua/plugins/bufferline.lua index f024880..634b981 100644 --- a/lua/plugins/bufferline.lua +++ b/lua/plugins/bufferline.lua @@ -1,19 +1,19 @@ require("bufferline").setup({ - options = { + options = { -- 使用 nvim 内置lsp - diagnostics = "nvim_lsp", + diagnostics = "nvim_lsp", diagnostics_indicator = function(count, level, diagnostics_dict) - return "("..count..")" - end, - always_show_bufferline = false, - -- 左侧让出 nvim-tree 的位置 - offsets = { - { - filetype = "NvimTree", - text = "File Explorer", - highlight = "Directory", - text_align = "left", - }, - }, - }, + return "(" .. count .. ")" + end, + always_show_bufferline = false, + -- 左侧让出 nvim-tree 的位置 + offsets = { + { + filetype = "NvimTree", + text = "File Explorer", + highlight = "Directory", + text_align = "left", + }, + }, + }, }) diff --git a/lua/plugins/debug.lua b/lua/plugins/debug.lua new file mode 100644 index 0000000..efde652 --- /dev/null +++ b/lua/plugins/debug.lua @@ -0,0 +1,7 @@ +require("dapui").setup() +require("nvim-dap-virtual-text").setup() +-- IMPORTANT: make sure to setup neodev BEFORE lspconfig +require("neodev").setup({ + -- add any options here, or leave empty to use the default settings + library = { plugins = { "nvim-dap-ui" }, types = true }, +}) diff --git a/lua/plugins/file-tree.lua b/lua/plugins/file-tree.lua index 80f2207..63c5551 100644 --- a/lua/plugins/file-tree.lua +++ b/lua/plugins/file-tree.lua @@ -7,36 +7,41 @@ vim.opt.termguicolors = true -- OR setup with some options require("nvim-tree").setup({ - sort_by = "case_sensitive", - view = { - width = 30, - mappings = { - list = { - { key = "u", action = "dir_up" }, - }, - }, - }, - renderer = { - group_empty = true, - }, - filters = { - dotfiles = true, - }, + auto_reload_on_write = true, + sort_by = "case_sensitive", + sync_root_with_cwd = true, + respect_buf_cwd = true, + update_focused_file = { + enable = true, + update_root = true, + }, + filters = { custom = { ".git" } }, + view = { + width = 30, + mappings = { + list = { + { key = "u", action = "dir_up" }, + }, + }, + }, + renderer = { + group_empty = true, + }, }) local function open_nvim_tree(data) - -- buffer is a directory - local directory = vim.fn.isdirectory(data.file) == 1 + -- buffer is a directory + local directory = vim.fn.isdirectory(data.file) == 1 - if not directory then - return - end + if not directory then + return + end - -- change to the directory - vim.cmd.cd(data.file) + -- change to the directory + vim.cmd.cd(data.file) - -- open the tree - require("nvim-tree.api").tree.open() + -- open the tree + require("nvim-tree.api").tree.open() end vim.api.nvim_create_autocmd({ "VimEnter" }, { callback = open_nvim_tree }) diff --git a/lua/plugins/golang.lua b/lua/plugins/golang.lua index 08c2a5d..55d30be 100644 --- a/lua/plugins/golang.lua +++ b/lua/plugins/golang.lua @@ -1,9 +1,9 @@ require("go").setup() local format_sync_grp = vim.api.nvim_create_augroup("GoImport", {}) vim.api.nvim_create_autocmd("BufWritePre", { - pattern = "*.go", - callback = function() - require("go.format").goimport() - end, - group = format_sync_grp, + pattern = "*.go", + callback = function() + require("go.format").goimport() + end, + group = format_sync_grp, }) diff --git a/lua/plugins/indent_blackline.lua b/lua/plugins/indent_blackline.lua index 5dfbb9c..5dd9c3b 100644 --- a/lua/plugins/indent_blackline.lua +++ b/lua/plugins/indent_blackline.lua @@ -3,8 +3,8 @@ vim.opt.listchars:append("space:⋅") vim.opt.listchars:append("eol:↴") require("indent_blankline").setup({ - show_current_context = true, - show_current_context_start = true, - show_end_of_line = true, - space_char_blankline = " ", + show_current_context = true, + show_current_context_start = true, + show_end_of_line = true, + space_char_blankline = " ", }) diff --git a/lua/plugins/leap.lua b/lua/plugins/leap.lua index 55daa00..61b7ca8 100644 --- a/lua/plugins/leap.lua +++ b/lua/plugins/leap.lua @@ -2,11 +2,11 @@ require("leap").add_default_mappings() require("leap").opts.highlight_unlabeled_phase_one_targets = true require("flit").setup({ - keys = { f = "f", F = "F", t = "t", T = "T" }, - -- A string like "nv", "nvo", "o", etc. - labeled_modes = "v", - multiline = true, - -- Like `leap`s similar argument (call-specific overrides). - -- E.g.: opts = { equivalence_classes = {} } - opts = {}, + keys = { f = "f", F = "F", t = "t", T = "T" }, + -- A string like "nv", "nvo", "o", etc. + labeled_modes = "v", + multiline = true, + -- Like `leap`s similar argument (call-specific overrides). + -- E.g.: opts = { equivalence_classes = {} } + opts = {}, }) diff --git a/lua/plugins/legendary.lua b/lua/plugins/legendary.lua new file mode 100644 index 0000000..b4f2aa3 --- /dev/null +++ b/lua/plugins/legendary.lua @@ -0,0 +1,9 @@ +-- 快捷键提示 +require("which-key").setup({}) +-- 自定义快捷键 +require("legendary").setup({ + which_key = { auto_register = true }, + extensions = { + -- load keymaps and commands from nvim-tree.lua + }, +}) diff --git a/lua/plugins/line-numbers.lua b/lua/plugins/line-numbers.lua deleted file mode 100644 index 876c00b..0000000 --- a/lua/plugins/line-numbers.lua +++ /dev/null @@ -1 +0,0 @@ -require("numbers").setup({}) diff --git a/lua/plugins/lspsaga.lua b/lua/plugins/lspsaga.lua index 5b73a68..5f7c9fa 100644 --- a/lua/plugins/lspsaga.lua +++ b/lua/plugins/lspsaga.lua @@ -1,13 +1,13 @@ require("lspsaga").setup({ - ui = { - colors = require("catppuccin.groups.integrations.lsp_saga").custom_colors(), - kind = require("catppuccin.groups.integrations.lsp_saga").custom_kind(), - }, + ui = { + colors = require("catppuccin.groups.integrations.lsp_saga").custom_colors(), + kind = require("catppuccin.groups.integrations.lsp_saga").custom_kind(), + }, }) require("lsp-colors").setup({ - Error = "#db4b4b", - Warning = "#e0af68", - Information = "#0db9d7", - Hint = "#10B981" + Error = "#db4b4b", + Warning = "#e0af68", + Information = "#0db9d7", + Hint = "#10B981", }) diff --git a/lua/plugins/lualine.lua b/lua/plugins/lualine.lua index 4b94233..449d0b4 100644 --- a/lua/plugins/lualine.lua +++ b/lua/plugins/lualine.lua @@ -1,40 +1,40 @@ require("lualine").setup({ - options = { - icons_enabled = true, - theme = "tokyonight", - component_separators = { left = "|", right = "|" }, - section_separators = { left = "", right = "" }, - disabled_filetypes = { - statusline = {}, - winbar = {}, - }, - ignore_focus = {}, - always_divide_middle = true, - globalstatus = false, - refresh = { - statusline = 1000, - tabline = 1000, - winbar = 1000, - }, - }, - sections = { - lualine_a = { "mode" }, - lualine_b = { "branch", "diff", "diagnostics" }, - lualine_c = { "filename" }, - lualine_x = { "encoding", "fileformat", "filetype" }, - lualine_y = { "progress" }, - lualine_z = { "location" }, - }, - inactive_sections = { - lualine_a = {}, - lualine_b = {}, - lualine_c = { "filename" }, - lualine_x = { "location" }, - lualine_y = {}, - lualine_z = {}, - }, - tabline = {}, - winbar = {}, - inactive_winbar = {}, - extensions = {}, + options = { + icons_enabled = true, + theme = "tokyonight", + component_separators = { left = "|", right = "|" }, + section_separators = { left = "", right = "" }, + disabled_filetypes = { + statusline = {}, + winbar = {}, + }, + ignore_focus = {}, + always_divide_middle = true, + globalstatus = false, + refresh = { + statusline = 1000, + tabline = 1000, + winbar = 1000, + }, + }, + sections = { + lualine_a = { "mode" }, + lualine_b = { "branch", "diff", "diagnostics" }, + lualine_c = { "filename" }, + lualine_x = { "encoding", "fileformat", "filetype" }, + lualine_y = { "progress" }, + lualine_z = { "location" }, + }, + inactive_sections = { + lualine_a = {}, + lualine_b = {}, + lualine_c = { "filename" }, + lualine_x = { "location" }, + lualine_y = {}, + lualine_z = {}, + }, + tabline = {}, + winbar = {}, + inactive_winbar = {}, + extensions = {}, }) diff --git a/lua/plugins/mason.lua b/lua/plugins/mason.lua index fcc4652..31dce0f 100644 --- a/lua/plugins/mason.lua +++ b/lua/plugins/mason.lua @@ -1,33 +1,36 @@ require("mason").setup({ - ui = { - icons = { - package_installed = "✓", - package_pending = "➜", - package_uninstalled = "✗", - }, - }, + ui = { + icons = { + package_installed = "✓", + package_pending = "➜", + package_uninstalled = "✗", + }, + }, }) require("mason-lspconfig").setup({ - ensure_installed = { - "lua_ls", - "rust_analyzer", - "gopls", - "golangci_lint_ls", - "tsserver", - "volar", - "taplo", - "lemminx", - "yamlls", - "sqlls", - "jsonls", - "jdtls", - "bashls", - "cssls", - "dockerls", - "docker_compose_language_service", - "eslint", - "html", - }, - automatic_installation = true, + ensure_installed = { + "clangd", + "emmet_ls", + "cmake", + "gradle_ls", + "kotlin_language_server", + "lua_ls", + "rust_analyzer", + "gopls", + "golangci_lint_ls", + "tsserver", + "volar", + "taplo", + "yamlls", + "jsonls", + "jdtls", + "bashls", + "cssls", + "dockerls", + "docker_compose_language_service", + "eslint", + "html", + }, + automatic_installation = true, }) diff --git a/lua/plugins/null-ls.lua b/lua/plugins/null-ls.lua index 2a5e01a..114f60a 100644 --- a/lua/plugins/null-ls.lua +++ b/lua/plugins/null-ls.lua @@ -1,43 +1,13 @@ local null_ls = require("null-ls") null_ls.setup({ - sources = { - null_ls.builtins.formatting.stylua, - null_ls.builtins.formatting.buf, - null_ls.builtins.formatting.clang_format, - null_ls.builtins.formatting.dart_format, - null_ls.builtins.formatting.eslint_d, - null_ls.builtins.formatting.fixjson, + sources = { + null_ls.builtins.formatting.stylua, null_ls.builtins.formatting.gofmt, - null_ls.builtins.formatting.goimports_reviser, - null_ls.builtins.formatting.google_java_format, - null_ls.builtins.formatting.markdownlint, - null_ls.builtins.formatting.markdown_toc, - null_ls.builtins.formatting.rustfmt, - null_ls.builtins.formatting.shfmt, - null_ls.builtins.formatting.taplo, - null_ls.builtins.formatting.xmllint, - null_ls.builtins.formatting.yamlfmt, + null_ls.builtins.formatting.eslint_d, + null_ls.builtins.formatting.protolint, -- 诊断 - null_ls.builtins.diagnostics.buf, - null_ls.builtins.diagnostics.checkmake, - null_ls.builtins.diagnostics.checkstyle, - null_ls.builtins.diagnostics.clang_check, - null_ls.builtins.diagnostics.cppcheck, null_ls.builtins.diagnostics.eslint_d, - null_ls.builtins.diagnostics.gitlint, - null_ls.builtins.diagnostics.golangci_lint, - null_ls.builtins.diagnostics.jsonlint, - null_ls.builtins.diagnostics.shellcheck, - null_ls.builtins.diagnostics.yamllint, - -- 动作 - null_ls.builtins.code_actions.eslint_d, - null_ls.builtins.code_actions.gitrebase, - null_ls.builtins.code_actions.gitsigns, - null_ls.builtins.code_actions.gomodifytags, - null_ls.builtins.code_actions.shellcheck, - null_ls.builtins.code_actions.xo, - -- 完成 - null_ls.builtins.completion.luasnip, - }, + null_ls.builtins.diagnostics.protolint, + }, }) diff --git a/lua/plugins/peaceful.lua b/lua/plugins/peaceful.lua new file mode 100644 index 0000000..104880a --- /dev/null +++ b/lua/plugins/peaceful.lua @@ -0,0 +1,12 @@ +-- url罗列 +require("urlview").setup({}) +-- 行号模式切换 +require("numbers").setup({}) +-- 终端管理 +require("toggleterm").setup({}) +-- 错误列表 +require("trouble").setup({}) +-- ui配置 +require("dressing").setup({}) +-- lsp状态 +require("fidget").setup({}) diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua index abbe2da..9f4d839 100644 --- a/lua/plugins/telescope.lua +++ b/lua/plugins/telescope.lua @@ -1 +1,47 @@ -require("telescope").setup({}) +-- 模糊搜索 +local telescope = require("telescope") +local actions = require("telescope.actions") +local themes = require("telescope.themes") +telescope.setup({ + defaults = themes.get_dropdown({ + path_display = { "absolute" }, + file_ignore_patterns = { ".git/", "node_modules" }, + mappings = { + i = { + [""] = actions.cycle_history_next, + [""] = actions.cycle_history_prev, + [""] = actions.cycle_history_next, + [""] = actions.cycle_history_prev, + [""] = actions.move_selection_next, + [""] = actions.move_selection_previous, + }, + }, + }), + extensions = { + fzf = { + fuzzy = true, -- false will only do exact matching + override_generic_sorter = true, -- override the generic sorter + override_file_sorter = true, -- override the file sorter + case_mode = "smart_case", -- or "ignore_case" or "respect_case" + -- the default case_mode is "smart_case" + }, + ["ui-select"] = { + require("telescope.themes").get_dropdown({ + -- even more opts + }), + }, + }, + pickers = { + find_files = { + hidden = true, + no_ignore = true, + no_ignore_parent = true, + }, + buffers = { + sort_mru = true, + }, + }, +}) + +telescope.load_extension("ui-select") +telescope.load_extension("fzf") diff --git a/lua/plugins/terminal.lua b/lua/plugins/terminal.lua deleted file mode 100644 index cee59f8..0000000 --- a/lua/plugins/terminal.lua +++ /dev/null @@ -1 +0,0 @@ -require("toggleterm").setup({}) diff --git a/lua/plugins/treesitter.lua b/lua/plugins/treesitter.lua index f2271b2..ab748e1 100644 --- a/lua/plugins/treesitter.lua +++ b/lua/plugins/treesitter.lua @@ -28,6 +28,7 @@ require("nvim-treesitter.configs").setup({ "vim", "vue", "yaml", + "proto", }, -- Install parsers synchronously (only applied to `ensure_installed`) sync_install = true, @@ -39,15 +40,15 @@ require("nvim-treesitter.configs").setup({ ---- If you need to change the installation directory of the parsers (see -> Advanced Setup) -- parser_install_dir = "/some/path/to/store/parsers", -- Remember to run vim.opt.runtimepath:append("/some/path/to/store/parsers")! - incremental_selection = { - enable = true, - keymaps = { - init_selection = "", - node_incremental = "", - node_decremental = "", - scope_incremental = "", - }, - }, + incremental_selection = { + enable = true, + keymaps = { + init_selection = "", + node_incremental = "", + node_decremental = "", + scope_incremental = "", + }, + }, indent = { enable = true, }, diff --git a/lua/plugins/trouble.lua b/lua/plugins/trouble.lua deleted file mode 100644 index 72ae661..0000000 --- a/lua/plugins/trouble.lua +++ /dev/null @@ -1 +0,0 @@ -require("trouble").setup({}) diff --git a/lua/plugins/wilder.lua b/lua/plugins/wilder.lua new file mode 100644 index 0000000..da3b63c --- /dev/null +++ b/lua/plugins/wilder.lua @@ -0,0 +1,52 @@ +local G = require("core.g") + +local wilder = require("wilder") +wilder.setup({ + modes = { ":", "/", "?" }, + next_key = 0, + previous_key = 0, + reject_key = 0, + accept_key = 0, +}) +wilder.set_option("pipeline", { + wilder.branch( + { + wilder.check(function(_, x) + return G.fn.empty(x) + end), + wilder.history(15), + }, + wilder.cmdline_pipeline({ + fuzzy = 1, + fuzzy_filter = wilder.vim_fuzzy_filter(), + }), + wilder.search_pipeline() + ), + wilder.debounce(10), +}) +wilder.set_option( + "renderer", + wilder.popupmenu_renderer(wilder.popupmenu_border_theme({ + highlights = { + accent = "WilderAccent", + selected_accent = "WilderSelectedAccent", + }, + highlighter = wilder.basic_highlighter(), + left = { " ", wilder.popupmenu_devicons() }, + right = { " ", wilder.popupmenu_scrollbar() }, + border = "rounded", + max_height = 17, -- 最大高度限制 因为要计算上下 所以17支持最多15个选项 + })) +) +G.cmd("silent! UpdateRemotePlugins") +G.hi({ + WilderAccent = { fg = 12 }, + WilderSelectedAccent = { fg = 12, bg = 239 }, +}) +G.map({ + { "c", "", [[wilder#in_context() ? wilder#next() : '']], { noremap = true, expr = true } }, + { "c", "", [[wilder#in_context() ? wilder#next() : '']], { noremap = true, expr = true } }, + { "c", "", [[wilder#in_context() ? wilder#previous() : '']], { noremap = true, expr = true } }, + { "c", "0", "0", {} }, -- 不清楚原因导致0无法使用 强制覆盖 +}) + diff --git a/lua/setup.lua b/lua/setup.lua index 7e661ed..71943e2 100644 --- a/lua/setup.lua +++ b/lua/setup.lua @@ -12,145 +12,212 @@ end local packer_bootstrap = ensure_packer() return require("packer").startup(function(use) - use({ "wbthomason/packer.nvim" }) - use({ "folke/tokyonight.nvim" }) - use({ "catppuccin/nvim", as = "catppuccin" }) + use({ + "https://github.com/lewis6991/impatient.nvim", + config = function() + require("impatient") + end, + }) + use({ "wbthomason/packer.nvim" }) + use({ "folke/tokyonight.nvim" }) + use({ "stevearc/dressing.nvim" }) + use({ "catppuccin/nvim", as = "catppuccin" }) - -- bufferline - use({ "akinsho/bufferline.nvim", tag = "v3.*", requires = "nvim-tree/nvim-web-devicons" }) - -- 行号模式自动切换 - use({ "nkakouros-original/numbers.nvim" }) - -- 模糊搜索 - use({ - "nvim-telescope/telescope.nvim", - tag = "0.1.1", - requires = { - { "nvim-lua/plenary.nvim" }, - { "nvim-treesitter/nvim-treesitter" }, - { "kdheepak/lazygit.nvim" }, - }, - }) - -- 文件树 - use({ - "nvim-tree/nvim-tree.lua", - requires = { - "nvim-tree/nvim-web-devicons", -- optional, for file icons - }, - tag = "nightly", -- optional, updated every week. (see issue #1193) - }) - -- 终端管理 - use({ "akinsho/toggleterm.nvim", tag = "*" }) - -- LSP管理器 - use({ - "williamboman/mason.nvim", - "williamboman/mason-lspconfig.nvim", - "neovim/nvim-lspconfig", - "jose-elias-alvarez/null-ls.nvim", - }) - -- 命令行 - use({ - "VonHeikemen/fine-cmdline.nvim", - requires = { - { "MunifTanjim/nui.nvim" }, - }, - }) - -- 通知 - use({ "rcarriga/nvim-notify" }) - - -- 缩进线 - use({ "lukas-reineke/indent-blankline.nvim" }) - -- 注释管理 - use({ - "numToStr/Comment.nvim", - config = function() - require("Comment").setup({}) - end, - }) - -- git管理 - use({ "lewis6991/gitsigns.nvim" }) - use({ - "nvim-lualine/lualine.nvim", - requires = { "kyazdani42/nvim-web-devicons", opt = true }, - }) - use({ - "windwp/nvim-autopairs", - config = function() - require("nvim-autopairs").setup({}) - end, - }) - use({ - "Pocco81/auto-save.nvim", - }) - use({ - "glepnir/lspsaga.nvim", - branch = "main", - requires = { - "nvim-tree/nvim-web-devicons", - --Please make sure you install markdown and markdown_inline parser - "nvim-treesitter/nvim-treesitter", - "folke/lsp-colors.nvim", - }, - }) - -- 错误列表 - use({ - "folke/trouble.nvim", - requires = "nvim-tree/nvim-web-devicons", - }) - -- 上下高亮跳动 - use({ "danilamihailov/beacon.nvim" }) - -- markdown lsp - use({ - "iamcco/markdown-preview.nvim", - run = "cd app && npm install", - setup = function() - vim.g.mkdp_filetypes = { "markdown" } - end, - ft = { "markdown" }, - }) - -- 跳转 - use({ "ggandor/leap.nvim" }) - use({ "ggandor/flit.nvim" }) - -- 项目管理 - use({ "ahmedkhalf/project.nvim" }) - -- 优化启动速度 - use({ "lewis6991/impatient.nvim" }) - -- TODO 管理 - use({ - "folke/todo-comments.nvim", - requires = "nvim-lua/plenary.nvim", - }) - -- 代码高亮 - use({ + -- bufferline + use({ "akinsho/bufferline.nvim", tag = "v3.*", requires = "nvim-tree/nvim-web-devicons" }) + -- 行号模式自动切换 + use({ "nkakouros-original/numbers.nvim" }) + -- 文件树 + use({ + "nvim-tree/nvim-tree.lua", + requires = { + "nvim-tree/nvim-web-devicons", -- optional, for file icons + }, + tag = "nightly", -- optional, updated every week. (see issue #1193) + }) + -- 终端管理 + use({ "akinsho/toggleterm.nvim", tag = "*" }) + -- LSP管理器 + use({ + "williamboman/mason.nvim", + "williamboman/mason-lspconfig.nvim", + "neovim/nvim-lspconfig", + "jose-elias-alvarez/null-ls.nvim", + }) + -- 命令行 + use({ + "VonHeikemen/fine-cmdline.nvim", + requires = { + { "MunifTanjim/nui.nvim" }, + }, + }) + -- 通知 + use({ "rcarriga/nvim-notify" }) + -- 缩进线 + use({ "lukas-reineke/indent-blankline.nvim" }) + -- 注释管理 + use({ + "numToStr/Comment.nvim", + config = function() + require("Comment").setup({}) + end, + }) + -- git管理 + use({ "lewis6991/gitsigns.nvim" }) + use({ + "nvim-lualine/lualine.nvim", + requires = { "kyazdani42/nvim-web-devicons", opt = true }, + }) + -- 自动修复部分按键 + use({ "tummetott/unimpaired.nvim" }) + -- 标签补全 + use({ "windwp/nvim-autopairs" }) + use({ "windwp/nvim-ts-autotag" }) + -- 自动保存 + use({ + "Pocco81/auto-save.nvim", + }) + -- lspsaga + use({ + "glepnir/lspsaga.nvim", + branch = "main", + requires = { + "nvim-tree/nvim-web-devicons", + --Please make sure you install markdown and markdown_inline parser "nvim-treesitter/nvim-treesitter", - run = ":TSUpdate", - }) - -- 自动完成相关 - use({ + "folke/lsp-colors.nvim", + }, + }) + -- 错误列表 + use({ + "folke/trouble.nvim", + requires = "nvim-tree/nvim-web-devicons", + }) + -- 上下高亮跳动 + use({ "danilamihailov/beacon.nvim" }) + -- markdown lsp + use({ "mzlogin/vim-markdown-toc", ft = "markdown" }) + use({ + "iamcco/markdown-preview.nvim", + run = "cd app && npm install", + setup = function() + vim.g.mkdp_filetypes = { "markdown" } + end, + ft = { "markdown" }, + }) + -- 跳转 + use({ "ggandor/leap.nvim" }) + use({ "ggandor/flit.nvim" }) + -- 项目管理 + use({ "ahmedkhalf/project.nvim" }) + -- TODO 管理 + use({ + "folke/todo-comments.nvim", + requires = "nvim-lua/plenary.nvim", + }) + -- 代码高亮 + use({ + "nvim-treesitter/nvim-treesitter", + run = ":TSUpdate", + }) + use({ "nvim-treesitter/playground", after = "nvim-treesitter" }) + -- 自动完成相关 + use({ + "hrsh7th/nvim-cmp", + requires = { + "onsails/lspkind-nvim", + "octaltree/cmp-look", + "hrsh7th/cmp-nvim-lsp", + "hrsh7th/cmp-buffer", + "hrsh7th/cmp-path", + "hrsh7th/cmp-calc", + "hrsh7th/cmp-cmdline", "hrsh7th/nvim-cmp", - requires = { - "onsails/lspkind-nvim", - "octaltree/cmp-look", - "hrsh7th/cmp-nvim-lsp", - "hrsh7th/cmp-buffer", - "hrsh7th/cmp-path", - "hrsh7th/cmp-calc", - "hrsh7th/cmp-cmdline", - "hrsh7th/nvim-cmp", - "hrsh7th/cmp-vsnip", - "hrsh7th/vim-vsnip", - "hrsh7th/cmp-emoji", - }, - }) - -- golang ide - use({ - "ray-x/go.nvim", - "ray-x/guihua.lua", -- recommended if need floating window support - }) - -- 高亮当前关键词 - use({ "RRethy/vim-illuminate" }) - - -- 自动保存 - if packer_bootstrap then - require("packer").sync() - end - end) + "hrsh7th/cmp-vsnip", + "hrsh7th/vim-vsnip", + "hrsh7th/cmp-emoji", + }, + }) + use({ + "L3MON4D3/LuaSnip", + requires = { + "rafamadriz/friendly-snippets", + }, + -- follow latest release. + tag = "v.*", + -- install jsregexp (optional!:). + run = "make install_jsregexp", + }) + -- golang ide + use({ + "ray-x/go.nvim", + "ray-x/guihua.lua", -- recommended if need floating window support + }) + -- 高亮当前关键词 + use({ "RRethy/vim-illuminate" }) + -- 罗列文件中的所有url + use("axieax/urlview.nvim") + -- 快捷键提示 + use({ + "folke/which-key.nvim", + config = function() + vim.o.timeout = true + vim.o.timeoutlen = 300 + end, + }) + -- debug + use({ + "theHamsta/nvim-dap-virtual-text", + "rcarriga/nvim-dap-ui", + "mfussenegger/nvim-dap", + "folke/neodev.nvim", + }) + -- 命令模式增强 + use({ + "gelguy/wilder.nvim", + config = function() + -- config goes here + end, + }) + -- lsp 状态 + use("nvim-lua/lsp-status.nvim") + -- 屏幕保护 + use("eandrju/cellular-automaton.nvim") + -- LSP 进度同步 + use({ + "https://github.com/j-hui/fidget.nvim", + config = function() + require("fidget").setup({ + text = { + spinner = "dots", + }, + }) + end, + }) + -- 模糊搜索 + use({ + "nvim-telescope/telescope.nvim", + tag = "0.1.1", + requires = { + { "nvim-lua/plenary.nvim" }, + { "nvim-treesitter/nvim-treesitter" }, + { "kdheepak/lazygit.nvim" }, + }, + }) + use({ + "https://github.com/nvim-telescope/telescope-fzf-native.nvim", + run = "make", + }) + use({ "nvim-telescope/telescope-ui-select.nvim" }) + -- 自定义命令 + use({ + "mrjones2014/legendary.nvim", + requires = "kkharji/sqlite.lua", + }) + -- protobuf 识别 + use("wfxr/protobuf.vim") + -- 自动保存 + if packer_bootstrap then + require("packer").sync() + end +end)