From c298571374a0a0ac06458d25cdb19ae14d249e32 Mon Sep 17 00:00:00 2001 From: jiangyinzuo Date: Sat, 6 Apr 2024 19:14:35 +0800 Subject: [PATCH] vimrc!: drop vim-plug support for neovim --- root/.config/nvim/lua/lsp/init.lua | 2 + root/.config/nvim/lua/plugins/vimplug.lua | 5 +- root/.config/nvim/vimplug.lua | 46 ----- .../plugin/project.vim | 0 root/.vim/vimrc | 22 +-- root/.vim/vimrc.d/ai.vim | 17 +- root/.vim/vimrc.d/plugin.vim | 174 +++++++++--------- root/.vim/vimrc.d/plugin_nvim.vim | 91 --------- 8 files changed, 104 insertions(+), 253 deletions(-) delete mode 100644 root/.config/nvim/vimplug.lua rename root/.vim/pack/my_plugins/start/{project => project.vim}/plugin/project.vim (100%) delete mode 100644 root/.vim/vimrc.d/plugin_nvim.vim diff --git a/root/.config/nvim/lua/lsp/init.lua b/root/.config/nvim/lua/lsp/init.lua index d8b707d..9524d14 100644 --- a/root/.config/nvim/lua/lsp/init.lua +++ b/root/.config/nvim/lua/lsp/init.lua @@ -88,6 +88,7 @@ local function setup_lsp(on_attach, capabilities) } lspconfig.texlab.setup { + autostart = vim.fn.get(vim.g.nvim_lsp_autostart, 'texlab', false), on_attach = on_attach, capabilities = capabilities, settings = { @@ -105,6 +106,7 @@ local function setup_lsp(on_attach, capabilities) -- ltex-ls.nvim似乎也不支持add to dictionary命令,建议使用coc.nvim lspconfig.ltex.setup { + autostart = vim.fn.get(vim.g.nvim_lsp_autostart, 'ltex', false), on_attach = on_attach, capabilities = capabilities, filetypes = { "bib", "tex", "latex" }, diff --git a/root/.config/nvim/lua/plugins/vimplug.lua b/root/.config/nvim/lua/plugins/vimplug.lua index 5c2356f..054aa07 100644 --- a/root/.config/nvim/lua/plugins/vimplug.lua +++ b/root/.config/nvim/lua/plugins/vimplug.lua @@ -120,10 +120,11 @@ local M = { }, { 'whonore/Coqtail', ft = 'coq' }, { - dir = "~/.vim/pack/my_plugins/start/project", + dir = "~/.vim/pack/my_plugins/start/project.vim", dependencies = { 'skywind3000/asynctasks.vim', - } + }, + priority = 2000, }, { dir = "~/.vim/pack/my_plugins/start/diffbuffer.vim" }, diff --git a/root/.config/nvim/vimplug.lua b/root/.config/nvim/vimplug.lua deleted file mode 100644 index 11ebc78..0000000 --- a/root/.config/nvim/vimplug.lua +++ /dev/null @@ -1,46 +0,0 @@ -local plugins_setup = require("plugins_setup") - -plugins_setup.nvim_treesitter() -plugins_setup.telescope() -plugins_setup.mason() -plugins_setup.gitsigns() -plugins_setup.auto_session() - -local neodev_config = {} -if vim.g.vim_dap == 'nvim-dap' then - require("dapconfig").dapconfig() - require("nvim-dap-virtual-text").setup({ - commented = true, - }) - neodev_config = { - -- add any options here, or leave empty to use the default settings - library = { plugins = { "nvim-dap-ui" }, types = true }, - } -end - -if vim.g.vimrc_lsp == 'nvim-lsp' then - -- IMPORTANT: make sure to setup neodev BEFORE lspconfig - require("neodev").setup(neodev_config) - require("lsp.init").lspconfig() - require("lsp.lsp_progress").lsp_progress() - require("outline").setup() -end - -plugins_setup.lualine() -require('nvim_cmp').nvim_cmp() - -if vim.g.ai_complete == 'copilot' then - require("CopilotChat").setup { - debug = true, -- Enable debugging - -- See Configuration section for rest - } -elseif vim.g.ai_complete == 'fittencode' then - require('fittencode').setup() -end - -require("nvim-devdocs").setup{} -require('Comment').setup() -require("todo-comments").setup() - --- load colorscheme at the end to avoid black background on startup -plugins_setup.colorscheme() diff --git a/root/.vim/pack/my_plugins/start/project/plugin/project.vim b/root/.vim/pack/my_plugins/start/project.vim/plugin/project.vim similarity index 100% rename from root/.vim/pack/my_plugins/start/project/plugin/project.vim rename to root/.vim/pack/my_plugins/start/project.vim/plugin/project.vim diff --git a/root/.vim/vimrc b/root/.vim/vimrc index b77dc26..71b36d1 100644 --- a/root/.vim/vimrc +++ b/root/.vim/vimrc @@ -4,16 +4,12 @@ if has('autocmd') " vim-tiny does not have autocmd """""""""""""""""""""" CONFIG """"""""""""""""""""""""""""""""" let g:vimrc_lsp = get(g:, 'vimrc_lsp', 'coc.nvim') - let g:vim_package_manager = get(g:, 'vim_package_manager', 'vim-plug') if has('nvim') let g:nvim_enable_inlayhints = 1 - if g:vim_package_manager == 'vim-plug' - set runtimepath^=~/.vim runtimepath+=~/.vim/after - let &packpath = &runtimepath - endif " autopair with nvim may has bug " https://github.com/neovim/neovim/issues/23666 let g:AutoPairsMapCR = 0 + let g:nvim_lsp_autostart = {} runtime clipboard_config.lua endif if filereadable(expand('~/.vim/config.vim')) @@ -186,10 +182,10 @@ if has('autocmd') " vim-tiny does not have autocmd if exists("g:vscode") let g:loaded_netrw = 1 let g:loaded_netrwPlugin = 1 - if g:vim_package_manager == 'vim-plug' - source ~/.vim/vimrc.d/plugin.vim - elseif has('nvim') && g:vim_package_manager == 'lazy.nvim' + if has('nvim') runtime lazy.lua + else + source ~/.vim/vimrc.d/plugin.vim endif finish endif @@ -401,10 +397,10 @@ if has('autocmd') " vim-tiny does not have autocmd helptags ~/.vim/doc endif if &loadplugins - if g:vim_package_manager == 'vim-plug' - source ~/.vim/vimrc.d/plugin.vim - elseif has('nvim') && g:vim_package_manager == 'lazy.nvim' + if has('nvim') runtime lazy.lua + else + source ~/.vim/vimrc.d/plugin.vim endif endif @@ -601,8 +597,4 @@ if has('autocmd') " vim-tiny does not have autocmd set csprg=gtags-cscope endif endif - - if g:no_plug == 0 && has('nvim') && !exists("g:vscode") && g:vim_package_manager == 'vim-plug' - runtime vimplug.lua - end endif diff --git a/root/.vim/vimrc.d/ai.vim b/root/.vim/vimrc.d/ai.vim index 6e6f896..195a898 100644 --- a/root/.vim/vimrc.d/ai.vim +++ b/root/.vim/vimrc.d/ai.vim @@ -1,4 +1,4 @@ -if has('nvim') || v:version >= 900 +if v:version >= 900 let g:vim_ai_roles_config_file = '~/.vim/vim-ai-roles.ini' " alternatives: https://github.com/codota/tabnine-nvim @@ -6,7 +6,7 @@ if has('nvim') || v:version >= 900 " copilot.vim在打开文件后,第一次快速进入插入模式时,存在卡顿的问题 " Github Coplit Support " https://docs.github.com/en/copilot/getting-started-with-github-copilot/getting-started-with-github-copilot-in-neovim?platform=linux - if g:vim_package_manager == 'vim-plug' + if !has('nvim') Plug 'github/copilot.vim' endif " use to auto complete github copilot @@ -38,7 +38,7 @@ if has('nvim') || v:version >= 900 elseif g:ai_complete == 'codeium' " Alternative: https://github.com/Exafunction/codeium.nvim - if g:vim_package_manager == 'vim-plug' + if !has('nvim') Plug 'Exafunction/codeium.vim' endif let g:codeium_disable_bindings = 1 @@ -53,12 +53,8 @@ if has('nvim') || v:version >= 900 imap (codeium-dismiss) endif elseif g:ai_complete == 'fittencode' - if g:vim_package_manager == 'vim-plug' - if has('nvim') - Plug 'luozhiya/fittencode.nvim' - else - Plug 'FittenTech/fittencode.vim' - endif + if !has('nvim') + Plug 'FittenTech/fittencode.vim' endif endif endif @@ -117,7 +113,8 @@ if has('python3') command -nargs=1 -complete=customlist,AISwitchServerComplete AISwitchServer call AISwitchServer() | echom g:vim_ai_endpoint_url . ' ' . g:vim_ai_token_file_path . ' ' . g:vim_ai_model - if g:vim_package_manager == 'vim-plug' + + if !has('nvim') Plug 'madox2/vim-ai' endif call AISwitchServer(get(g:, 'ai_service', 'aiproxy')) diff --git a/root/.vim/vimrc.d/plugin.vim b/root/.vim/vimrc.d/plugin.vim index 5a795bf..43560e8 100644 --- a/root/.vim/vimrc.d/plugin.vim +++ b/root/.vim/vimrc.d/plugin.vim @@ -50,7 +50,7 @@ if !exists('g:vscode') Plug 'lambdalisue/fern-hijack.vim' Plug 'LumaKernel/fern-mapping-fzf.vim' - if has('nvim') || v:version >= 800 + if v:version >= 800 Plug 'brooth/far.vim', {'on': ['Far', 'Farf', 'Farp', 'Farr']} Plug 'preservim/vimux' Plug 'SirVer/ultisnips' @@ -83,100 +83,96 @@ if !exists('g:vscode') Plug 'godlygeek/tabular' Plug 'axvr/org.vim', { 'for': 'org' } Plug 'kaarmu/typst.vim', { 'for': 'typst' } - if (v:version >= 802 || has('nvim')) && g:vimrc_lsp == 'coc.nvim' + if v:version >= 802 " Use release branch (recommend) Plug 'neoclide/coc.nvim', {'branch': 'release'} Plug 'antoinemadec/coc-fzf' endif - if has('nvim') - source ~/.vim/vimrc.d/plugin_nvim.vim + " Plug 'nordtheme/vim', { 'as': 'nordtheme' } + " Plug 'dracula/vim', { 'as': 'dracula' } + " Plug 'tomasiser/vim-code-dark' + " Plug 'morhetz/gruvbox' + + " Commenting blocks of code. + " 可以选中多行后,用:norm i# 在所有行前面添加# + " :norm 0i 在所有行前面添加 + " :norm ^i 在所有行前面添加(不包括空格) + " :norm 0x删除所有行的第一个字母 + " :norm ^x删除所有行的第一个字母(不包括空格) + " + " Replace custom commands for commenting. + " Since: v0.12.0 + " See Also: https://stackoverflow.com/questions/1676632/whats-a-quick-way-to-comment-uncomment-lines-in-vim + Plug 'tpope/vim-commentary' + Plug 'tpope/vim-endwise' + + " Remove ~/.vim/autoload/detect_indent.vim + " Since: v0.12.0 + if v:version >= 901 + packadd! editorconfig else - " Plug 'nordtheme/vim', { 'as': 'nordtheme' } - " Plug 'dracula/vim', { 'as': 'dracula' } - " Plug 'tomasiser/vim-code-dark' - " Plug 'morhetz/gruvbox' - - " Commenting blocks of code. - " 可以选中多行后,用:norm i# 在所有行前面添加# - " :norm 0i 在所有行前面添加 - " :norm ^i 在所有行前面添加(不包括空格) - " :norm 0x删除所有行的第一个字母 - " :norm ^x删除所有行的第一个字母(不包括空格) - " - " Replace custom commands for commenting. - " Since: v0.12.0 - " See Also: https://stackoverflow.com/questions/1676632/whats-a-quick-way-to-comment-uncomment-lines-in-vim - Plug 'tpope/vim-commentary' - Plug 'tpope/vim-endwise' - - " Remove ~/.vim/autoload/detect_indent.vim - " Since: v0.12.0 - if v:version >= 901 - packadd! editorconfig - else - Plug 'editorconfig/editorconfig-vim' - endif - let g:EditorConfig_exclude_patterns = ['fugitive://.*', 'gitdiff://.*', 'scp://.*'] - au FileType gitcommit let b:EditorConfig_disable = 1 - " vim-sleuth does not behave as expected. - " Plug 'tpope/vim-sleuth' - - if v:version >= 800 - Plug 'lifepillar/vim-solarized8' - source ~/.vim/vimrc.d/leaderf.vim - if v:version >= 802 - " neovim 内置了 inccommand, 无需该插件 - Plug 'markonm/traces.vim' - " Alternative? https://github.com/jasonccox/vim-wayland-clipboard - " See: - " https://github.com/vim/vim/pull/9639 - " https://github.com/vim/vim/releases/tag/v9.1.0064 - Plug 'ojroques/vim-oscyank', {'branch': 'main'} - - if v:version >= 900 - " Alternative: https://github.com/gelguy/wilder.nvim - Plug 'girishji/autosuggest.vim' - " External cmd is slow. - autocmd VimEnter * ++once if exists('*g:AutoSuggestSetup') | call g:AutoSuggestSetup({ 'cmd': { 'exclude': ['!', '^Git\s', '^Floaterm'] }}) | endif - if v:version >= 901 - Plug 'girishji/devdocs.vim', {'on': ['DevdocsFind', 'DevdocsInstrall', 'DevdocsUninstall', 'DevdocsTagStack']} - endif - endif - if g:vim_dap == 'vimspector' - Plug 'puremourning/vimspector' - let g:vimspector_enable_mappings='VISUAL_STUDIO' - - " See: https://puremourning.github.io/vimspector/configuration.html#configuration-format - " There are two locations for debug configurations for a project: - " - " g:vimspector_configurations vim variable (dict) - " /configurations///*.json - " .vimspector.json in the project source - " - " json配置位于.vim/configurationsw目录下 - let g:vimspector_base_dir = $HOME . '/.vim' - let g:vimspector_sign_priority = { - \ 'vimspectorBP': 20, - \ 'vimspectorBPCond': 20, - \ 'vimspectorBPLog': 20, - \ 'vimspectorBPDisabled': 20, - \ 'vimspectorNonActivePC': 20, - \ 'vimspectorPC': 999, - \ 'vimspectorPCBP': 999, - \ } + Plug 'editorconfig/editorconfig-vim' + endif + let g:EditorConfig_exclude_patterns = ['fugitive://.*', 'gitdiff://.*', 'scp://.*'] + au FileType gitcommit let b:EditorConfig_disable = 1 + " vim-sleuth does not behave as expected. + " Plug 'tpope/vim-sleuth' + + if v:version >= 800 + Plug 'lifepillar/vim-solarized8' + source ~/.vim/vimrc.d/leaderf.vim + if v:version >= 802 + " neovim 内置了 inccommand, 无需该插件 + Plug 'markonm/traces.vim' + " Alternative? https://github.com/jasonccox/vim-wayland-clipboard + " See: + " https://github.com/vim/vim/pull/9639 + " https://github.com/vim/vim/releases/tag/v9.1.0064 + Plug 'ojroques/vim-oscyank', {'branch': 'main'} + + if v:version >= 900 + " Alternative: https://github.com/gelguy/wilder.nvim + Plug 'girishji/autosuggest.vim' + " External cmd is slow. + autocmd VimEnter * ++once if exists('*g:AutoSuggestSetup') | call g:AutoSuggestSetup({ 'cmd': { 'exclude': ['!', '^Git\s', '^Floaterm'] }}) | endif + if v:version >= 901 + Plug 'girishji/devdocs.vim', {'on': ['DevdocsFind', 'DevdocsInstrall', 'DevdocsUninstall', 'DevdocsTagStack']} endif - Plug 'jiangyinzuo/term-debugger' endif + if g:vim_dap == 'vimspector' + Plug 'puremourning/vimspector' + let g:vimspector_enable_mappings='VISUAL_STUDIO' + + " See: https://puremourning.github.io/vimspector/configuration.html#configuration-format + " There are two locations for debug configurations for a project: + " + " g:vimspector_configurations vim variable (dict) + " /configurations///*.json + " .vimspector.json in the project source + " + " json配置位于.vim/configurationsw目录下 + let g:vimspector_base_dir = $HOME . '/.vim' + let g:vimspector_sign_priority = { + \ 'vimspectorBP': 20, + \ 'vimspectorBPCond': 20, + \ 'vimspectorBPLog': 20, + \ 'vimspectorBPDisabled': 20, + \ 'vimspectorNonActivePC': 20, + \ 'vimspectorPC': 999, + \ 'vimspectorPCBP': 999, + \ } + endif + Plug 'jiangyinzuo/term-debugger' endif - - Plug 'airblade/vim-gitgutter' - let g:gitgutter_sign_priority = 10 - omap ih (GitGutterTextObjectInnerPending) - omap ah (GitGutterTextObjectOuterPending) - xmap ih (GitGutterTextObjectInnerVisual) - xmap ah (GitGutterTextObjectOuterVisual) endif + Plug 'airblade/vim-gitgutter' + let g:gitgutter_sign_priority = 10 + omap ih (GitGutterTextObjectInnerPending) + omap ah (GitGutterTextObjectOuterPending) + xmap ih (GitGutterTextObjectInnerVisual) + xmap ah (GitGutterTextObjectOuterVisual) + " FZF :Commits依赖vim-fugitive Plug 'tpope/vim-fugitive' " A git commit browser. @@ -284,14 +280,14 @@ endif """""""""""""""""" begin colorscheme " 防止neovim启动时屏幕暂时变成黑色 -if !has('nvim') && has("termguicolors") && ($COLORTERM == 'truecolor' || g:vimrc_use_true_color) +if has("termguicolors") && ($COLORTERM == 'truecolor' || g:vimrc_use_true_color) set termguicolors endif let g:nord_uniform_diff_background = 1 let g:dracula_high_contrast_diff = 1 " 防止neovim启动时屏幕暂时变成黑色 -if v:version >= 800 && !has('nvim') +if v:version >= 800 " true color support " https://github.com/lifepillar/vim-solarized8#troubleshooting let &t_8f = "\[38;2;%lu;%lu;%lum" @@ -309,11 +305,11 @@ hi debugPC term=reverse ctermbg=4 guibg=DarkBlue hi debugBreakpoint term=reverse ctermbg=red guibg=red """""""""""""""""" end colorscheme -if (v:version >= 802 || has('nvim')) && g:vimrc_lsp == 'coc.nvim' +if v:version >= 802 && g:vimrc_lsp == 'coc.nvim' source ~/.vim/vimrc.d/coc.vim endif -if has('nvim') || v:version >= 801 +if v:version >= 801 let g:AutoPairs = autopairs#AutoPairsDefine([ \ {"open": "<", "close": ">", "filetype": ["html"]} \ ]) " This is a filetype-specific mapping diff --git a/root/.vim/vimrc.d/plugin_nvim.vim b/root/.vim/vimrc.d/plugin_nvim.vim deleted file mode 100644 index 78151e1..0000000 --- a/root/.vim/vimrc.d/plugin_nvim.vim +++ /dev/null @@ -1,91 +0,0 @@ -" Plug 'folke/tokyonight.nvim', { 'branch': 'main' } -Plug 'ishan9299/nvim-solarized-lua' -Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'} -Plug 'RRethy/nvim-treesitter-endwise' - -Plug 'nvim-lualine/lualine.nvim' -" If you want to have icons in your statusline choose one of these -Plug 'nvim-tree/nvim-web-devicons' - -Plug 'numToStr/Comment.nvim' -Plug 'folke/todo-comments.nvim' - -if g:vimrc_lsp == 'nvim-lsp' - Plug 'neovim/nvim-lspconfig' - Plug 'linrongbin16/lsp-progress.nvim' - Plug 'hedyhli/outline.nvim' - Plug 'p00f/clangd_extensions.nvim' - Plug 'mrcjkb/rustaceanvim', {'for': 'rust'} - - Plug 'hrsh7th/cmp-nvim-lsp' -endif - -" lsp for neovim itself -Plug 'folke/neodev.nvim' -Plug 'williamboman/mason.nvim' -" JSON schema -" Plug 'b0o/schemastore.nvim' -" Replace jose-elias-alvarez/null-ls.nvim -" Plug 'nvimtools/none-ls.nvim' - -""" DAP -Plug 'nvim-neotest/nvim-nio' -Plug 'mfussenegger/nvim-dap' -Plug 'rcarriga/nvim-dap-ui' -Plug 'theHamsta/nvim-dap-virtual-text' -""" - -Plug 'SmiteshP/nvim-navic' - -""" Telescope -Plug 'nvim-lua/plenary.nvim' -Plug 'nvim-telescope/telescope.nvim', { 'branch': '0.1.x' } -Plug 'aaronhallaert/advanced-git-search.nvim' -Plug 'nvim-telescope/telescope-file-browser.nvim' -Plug 'nvim-telescope/telescope-media-files.nvim' -Plug 'nvim-telescope/telescope-fzf-native.nvim', { 'do': 'make' } -Plug 'rmagatti/auto-session' -Plug 'rmagatti/session-lens' -""" - -Plug 'hrsh7th/cmp-buffer' -Plug 'hrsh7th/cmp-path' -Plug 'hrsh7th/cmp-cmdline' -Plug 'hrsh7th/nvim-cmp' -" completion(use ultisnips) -Plug 'quangnguyen30192/cmp-nvim-ultisnips' -Plug 'uga-rosa/cmp-dictionary' -Plug 'hrsh7th/cmp-omni' -Plug 'micangl/cmp-vimtex' - -Plug 'CopilotC-Nvim/CopilotChat.nvim', { 'branch': 'canary', 'on': [ - \ 'CopilotChat', - \ 'CopilotChatFixDiagnostic', - \ 'CopilotChatFix', - \ 'CopilotChatOpen', - \ 'CopilotChatReset', - \ 'CopilotChatOptimize', - \ 'CopilotChatTests', - \ 'CopilotChatExplain', - \ 'CopilotChatDebugInfo', - \ 'CopilotChatClose', - \ 'CopilotChatDocs', - \ 'CopilotChatCommit', - \ 'CopilotChatCommitStaged', - \ 'CopilotChatToggle']} - -Plug 'sindrets/diffview.nvim' - -Plug 'luckasRanarison/nvim-devdocs', { 'on': [ 'DevdocsOpen', - \ 'DevdocsFetch', - \ 'DevdocsToggle', - \ 'DevdocsUpdate', - \ 'DevdocsInstall', - \ 'DevdocsOpenFloat', - \ 'DevdocsUninstall', - \ 'DevdocsUpdateAll', - \ 'DevdocsKeywordprg', - \ 'DevdocsOpenCurrent', - \ 'DevdocsOpenCurrentFloat' - \ ]} -Plug 'lewis6991/gitsigns.nvim'