Xinqi Bao's Git

refactor(nvim): simplify config and remove unused settings
authorXinqi Bao <[email protected]>
Sun, 18 Jan 2026 14:44:17 +0000 (22:44 +0800)
committerXinqi Bao <[email protected]>
Sun, 18 Jan 2026 14:45:29 +0000 (22:45 +0800)
- 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

.config/nvim/init.vim
.config/nvim/lua/plugin-config/nvim-treesitter.lua

index acece76..950436a 100644 (file)
@@ -48,7 +48,7 @@ set undodir=~/.cache/nvim/undodir
 set undofile
 
 " auto added comment leader, detail for :h formatoptions
 set undofile
 
 " auto added comment leader, detail for :h formatoptions
-set formatoptions+=/
+set formatoptions+=/ro
 
 set tags=tags~;,tags~
 "setting gf (go file) path
 
 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 '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'
 
     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 '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 'neoclide/coc.nvim', {'branch': 'release'}
 
     Plug 'nvim-treesitter/nvim-treesitter'
-    "Plug 'mfussenegger/nvim-dap'
-    "Plug 'puremourning/vimspector'
 
     """
     "" avante and its dependents
 
     """
     "" avante and its dependents
@@ -175,23 +169,6 @@ if has_key(plugs, 'tagbar')
     nnoremap <leader>t :TagbarToggle<CR>
 endif
 
     nnoremap <leader>t :TagbarToggle<CR>
 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 <silent> <leader>gd :YcmCompleter GoTo<CR>
-    nnoremap <silent> <leader>gr :YcmCompleter GoToReferences<CR>
-endif
-
 "----------------------
 " coc.vim setting
 "----------------------
 "----------------------
 " coc.vim setting
 "----------------------
@@ -256,7 +233,8 @@ endif
 if has_key(plugs, 'nvim-treesitter')
     lua require('plugin-config/nvim-treesitter')
 
 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
     set foldexpr=nvim_treesitter#foldexpr()
     set foldlevel=99
 endif
@@ -287,6 +265,10 @@ nnoremap <silent> <Leader>v- :vertical resize -5<CR>
 nnoremap <silent> <Leader>fi :set foldmethod=indent<CR>
 nnoremap <silent> <Leader>fd :set foldmethod=manual<CR>ggVGzD
 
 nnoremap <silent> <Leader>fi :set foldmethod=indent<CR>
 nnoremap <silent> <Leader>fd :set foldmethod=manual<CR>ggVGzD
 
+" 禁用 <C-a>
+nnoremap <C-a> <Nop>
+xnoremap <C-a> <Nop>
+
 "HighLight trailing whitespace"
 highlight ExtraWhitespace ctermbg=red guibg=red
 match ExtraWhitespace /\s\+$/
 "HighLight trailing whitespace"
 highlight ExtraWhitespace ctermbg=red guibg=red
 match ExtraWhitespace /\s\+$/
index e61710a..ab75996 100644 (file)
@@ -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
 
   -- 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,
 
 
   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
     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,
         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,
   },
     additional_vim_regex_highlighting = false,
   },
-
-  -- Incremental selection based on the named nodes from the grammar.
-  incremental_selection = {
-    enable = true,
-    keymaps = {
-      init_selection    = '<CR>',
-      node_incremental  = '<CR>',
-      node_decremental  = '<BS>',
-      scope_incremental = '<TAB>',
-    }
-  },
-
-  -- Indentation based on treesitter for the = operator. NOTE: This is an experimental feature.
-  indent = {
-    enable = false
-  }
 }
 }