From: Xinqi Bao Date: Sun, 18 Jan 2026 14:44:17 +0000 (+0800) Subject: refactor(nvim): simplify config and remove unused settings X-Git-Url: https://git.xinqibao.xyz/dotfiles.git/commitdiff_plain/754f05fab08d7734f656cd7b67a119699ce9e6b9?ds=inline;hp=809fae34e618497ddee3d8028e7addafc5846df2 refactor(nvim): simplify config and remove unused settings - remove YouCompleteMe related config - remove commented out plugin entries - simplify treesitter config with new API - switch to indent-based folding - disable C-a in normal and visual mode --- diff --git a/.config/nvim/init.vim b/.config/nvim/init.vim index acece76..950436a 100644 --- a/.config/nvim/init.vim +++ b/.config/nvim/init.vim @@ -48,7 +48,7 @@ set undodir=~/.cache/nvim/undodir set undofile " auto added comment leader, detail for :h formatoptions -set formatoptions+=/ +set formatoptions+=/ro set tags=tags~;,tags~ "setting gf (go file) path @@ -74,7 +74,6 @@ call plug#begin() Plug 'Yggdroot/indentLine' Plug 'christoomey/vim-tmux-navigator' Plug 'vim-airline/vim-airline' - "Plug 'vim-airline/vim-airline-themes' Plug 'junegunn/fzf', { 'do': { -> fzf#install() } } Plug 'junegunn/fzf.vim' @@ -90,14 +89,9 @@ call plug#begin() Plug 'airblade/vim-gitgutter' Plug 'kdheepak/lazygit.nvim' - "Plug 'ycm-core/YouCompleteMe' - "Plug 'rhysd/vim-clang-format' - Plug 'neoclide/coc.nvim', {'branch': 'release'} Plug 'nvim-treesitter/nvim-treesitter' - "Plug 'mfussenegger/nvim-dap' - "Plug 'puremourning/vimspector' """ "" avante and its dependents @@ -175,23 +169,6 @@ if has_key(plugs, 'tagbar') nnoremap t :TagbarToggle endif -"---------------------- -" YouCompleteMe setting -"---------------------- -if has_key(plugs, 'YouCompleteMe') - let g:ycm_global_ycm_extra_conf = '~/.config/nvim/ycm_extra_conf.py' - let g:ycm_confirm_extra_conf = 0 - let g:ycm_enable_diagnostic_signs = 0 - let g:ycm_always_populate_location_list = 1 - "let g:ycm_show_diagnostics_ui = 0 - let g:ycm_add_preview_to_completeopt = 1 - let g:ycm_autoclose_preview_window_after_completion = 1 - let g:ycm_auto_hover = 'no' - - nnoremap gd :YcmCompleter GoTo - nnoremap gr :YcmCompleter GoToReferences -endif - "---------------------- " coc.vim setting "---------------------- @@ -256,7 +233,8 @@ endif if has_key(plugs, 'nvim-treesitter') lua require('plugin-config/nvim-treesitter') - set foldmethod=expr + "set foldmethod=expr + set foldmethod=indent set foldexpr=nvim_treesitter#foldexpr() set foldlevel=99 endif @@ -287,6 +265,10 @@ nnoremap v- :vertical resize -5 nnoremap fi :set foldmethod=indent nnoremap fd :set foldmethod=manualggVGzD +" 禁用 +nnoremap +xnoremap + "HighLight trailing whitespace" highlight ExtraWhitespace ctermbg=red guibg=red match ExtraWhitespace /\s\+$/ diff --git a/.config/nvim/lua/plugin-config/nvim-treesitter.lua b/.config/nvim/lua/plugin-config/nvim-treesitter.lua index e61710a..ab75996 100644 --- a/.config/nvim/lua/plugin-config/nvim-treesitter.lua +++ b/.config/nvim/lua/plugin-config/nvim-treesitter.lua @@ -1,65 +1,22 @@ -require'nvim-treesitter.configs'.setup { - --[[ - ]] - -- A list of parser names, or "all" (the five listed parsers should always be installed) - ensure_installed = { - "c", "cpp", "python", "lua", "bash", - "cmake", "make", - "json", "yaml", - "vim", "vimdoc", - "query", "regex", "comment", "markdown", - }, - - -- Install parsers synchronously (only applied to `ensure_installed`) - sync_install = false, +require'nvim-treesitter'.setup { + -- A list of parser names, or "all" + ensure_installed = { "c", "lua", "vim", "vimdoc", "query" }, -- Automatically install missing parsers when entering buffer -- Recommendation: set to false if you don't have `tree-sitter` CLI installed locally - auto_install = false, - - -- List of parsers to ignore installing (or "all") - ignore_install = { "javascript" }, - - ---- 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")! + auto_install = true, highlight = { enable = true, - -- NOTE: these are the names of the parsers and not the filetype. (for example if you want to - -- disable highlighting for the `tex` filetype, you need to include `latex` in this list as this is - -- the name of the parser) - -- 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 + -- 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)) + local ok, stats = pcall(vim.uv.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). - -- Using this option may slow down your editor, and you may see some duplicate highlights. - -- Instead of true it can also be a list of languages additional_vim_regex_highlighting = false, }, - - -- Incremental selection based on the named nodes from the grammar. - incremental_selection = { - enable = true, - keymaps = { - init_selection = '', - node_incremental = '', - node_decremental = '', - scope_incremental = '', - } - }, - - -- Indentation based on treesitter for the = operator. NOTE: This is an experimental feature. - indent = { - enable = false - } }