Vim

Neovim 配置出错

Posted by KalosAner on June 14, 2025

问题

使用 Neovim 0.11 配置 treesitter 时总是报错如下,安装 Lunarvim 同样如此。 Error in decoration provider “win” (ns=nvim.treesitter.highlighter): Error executing lua: …2/share/nvim/runtime/lua/vim/treesitter/languagetree.lua:208: Vim:E475: Invalid value for argument type: b stack traceback: [C]: in function ‘f’ …2/share/nvim/runtime/lua/vim/treesitter/languagetree.lua:208: in function ‘tcall’ …2/share/nvim/runtime/lua/vim/treesitter/languagetree.lua:530: in function ‘parse’ ….2/share/nvim/runtime/lua/vim/treesitter/highlighter.lua:471: in function <….2/share/nvim/runtime/lua/vim/treesitter/highlighter.lua :464>

treesitter 配置如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
require'nvim-treesitter.configs'.setup {
  -- 添加不同语言
  ensure_installed = { "vim", "bash", "c", "cpp", "javascript", "json", "lua", "python", "typescript", "tsx", "css", "rust", "markdown", "markdown_inline" }, -- one of "all" or a list of languages

  highlight = { 
    enable = true,
    additional_vim_regex_highlighting = false
  },
--  indent = { enable = true },

  -- 不同括号颜色区分
  rainbow = {
    enable = true,
    extended_mode = true,
    max_file_lines = nil,
  }
}

原因

Neovim 0.11 和 treesitter 中的 rainbow 不兼容。 没找到比较好的解决办法,我直接把 rainbow 注释掉了。