Eric's Blog 时光荏苒,岁月如梭

更新 Neovim 遇到的问题

2024-03-11
Eric Wong

起因

因为在维护 SpaceVim 这一项目,虽然我自己目前日常使用 neovim-0.9.5,但是还有不少用户会使用 neovim-nightly 版本。 因此,升级至每日构建版本测试 SpaceVim。

升级 Neovim

Windows 下升级也比较简单,使用 scoop 命令即可:

scoop uninstall neovim
scoop install neovim-nightly

不兼容的改动

安装后,启动一堆错误,也做了一部分修复,commits 如下:

* 2ad0da42 - perf(treesitter): add default setup function (Eric Wong 49 minutes ago)
* f8b280e0 - fix(flygrep): remove `t_ve` option (Eric Wong 68 minutes ago)
* c46968d5 - fix(colorscheme): link WinSeparator to VertSplit (Eric Wong 79 minutes ago)
* 9ee8606e - fix(telescope): fix deoplete autocmd (Eric Wong 82 minutes ago)
* 74c93c6c - chore(treesitter): update nvim-treesitter to 0.9.1 for Nvim-0.8.x (Eric Wong 2 hours ago)

vim.o.v_te 报错

原先,在我的代码里有很多通过设置 &v_te 选项来实现修改光标的造型。但是升级到新版本后,就报如下错误:

Error detected while processing function SpaceVim#plugins#flygrep#open:
line    1:
E5108: Error executing lua C:\Users\wsdjeg\.SpaceVim\/lua/spacevim/plugin/flygrep.lua:780: Unknown option 't_ve'
stack traceback:
	[C]: in function '__index'
	C:\Users\wsdjeg\.SpaceVim\/lua/spacevim/plugin/flygrep.lua:780: in function 'open'
	[string ":lua"]:1: in main chunk

检查了下源码,原来是因为执行了 vim.o.v_te,尝试做了一些测试,增加exists()判断,可恨的是 exists('&t_ve') 居然返回 1。 那么就无法判断了,只能是删除这些设置。

窗口分割高亮 VertSplit 失效

更新后,分割窗口的竖线没有高亮了。查了下 :hi VertSplit,输出结果显示高亮设置正常。看了 :h hl-VertSplit 才知道,原来分割窗口的高亮组名称修改了。 修改成了 WinSeparator。因此在 ColorScheme 的 autocmd 内增加了:

hi link WinSeparator VertSplit

treesitter 高亮报错

这是我遇到最无语的错误。每当打开 lua 文件、help 文件 就会弹出报错 treesitter parser 不存在。起初我以为是 nvim-treesitter 的问题,更新并增加配置禁用所有的高亮都不行。

报错如下:

Error detected while processing function startify#open_buffers[13]..<SNR>276_open_buffer[12]..BufReadPost Autocommands for "*":
Error executing lua callback: ...s\neovim-nightly\current\share\nvim\runtime\filetype.lua:30: Error executing lua: ...s\neovim-nightly\current\share\nvim\runtime\filetype.lua:31: function startify#open_buffers[13]..<SNR>276_open_buffer[12]..BufReadPost Autocommands for "*"..FileType Autocommands for "*"..function <SNR>1_LoadFTPlugin[20]..script D:\Scoop\apps\neovim-nightly\current\share\nvim\runtime\ftplugin\lua.lua: Vim(runtime):E5113: Error while calling lua chunk: ...rrent\share\nvim\runtime/lua/vim/treesitter/language.lua:104: no parser for 'lua' language, see :help treesitter-parsers
stack traceback:
	[C]: in function 'error'
	...rrent\share\nvim\runtime/lua/vim/treesitter/language.lua:104: in function 'add'
	...t\share\nvim\runtime/lua/vim/treesitter/languagetree.lua:112: in function 'new'
	...ightly\current\share\nvim\runtime/lua/vim/treesitter.lua:41: in function '_create_parser'
	...ightly\current\share\nvim\runtime/lua/vim/treesitter.lua:108: in function 'get_parser'
	...ightly\current\share\nvim\runtime/lua/vim/treesitter.lua:416: in function 'start'
	...ovim-nightly\current\share\nvim\runtime\ftplugin\lua.lua:2: in main chunk

执行 :help treesitter-parsers 同样报错,理解为打开 help 文件也报错,同只执行 :h

Error detected while processing modelines[274]..FileType Autocommands for "*"..function <SNR>1_LoadFTPlugin[20]..script D:\Scoop\apps\neovim-nightly\current\share\nvim\runtime\ftplugin\help.lua:
E5113: Error while calling lua chunk: ...rrent\share\nvim\runtime/lua/vim/treesitter/language.lua:104: no parser for 'vimdoc' language, see :help treesitter-parsers
stack traceback:
	[C]: in function 'error'
	...rrent\share\nvim\runtime/lua/vim/treesitter/language.lua:104: in function 'add'
	...t\share\nvim\runtime/lua/vim/treesitter/languagetree.lua:112: in function 'new'
	...ightly\current\share\nvim\runtime/lua/vim/treesitter.lua:41: in function '_create_parser'
	...ightly\current\share\nvim\runtime/lua/vim/treesitter.lua:108: in function 'get_parser'
	...ightly\current\share\nvim\runtime/lua/vim/treesitter.lua:416: in function 'start'
	...vim-nightly\current\share\nvim\runtime\ftplugin\help.lua:2: in main chunk

于是,禁用 SpaceVim 的 treesitter 模块,任然报错。查看了 neovim-nightly 的源码,发现,原来在这几个文件里面默认增加了:vim.treesitter.start()

  • D:\Scoop\apps\neovim-nightly\current\share\nvim\runtime\ftplugin\help.lua
  • D:/Scoop/apps/neovim-nightly/0.10.0-2559/share/nvim/runtime/ftplugin/lua.lua
  • 等等,懒得去一个个搜了。

执行 cat D:/Scoop/apps/neovim-nightly/0.10.0-2559/share/nvim/runtime/ftplugin/lua.lua, 发现就两行代码,也没有任何条件判断跟 error handle。

-- use treesitter over syntax
vim.treesitter.start()

切回稳定版

说实话,没空去这样试错。

scoop uninstall neovim-nightly
scoop install neovim
nvim --version
NVIM v0.9.5
Build type: RelWithDebInfo
LuaJIT 2.1.1703942320
Compilation: C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe /MD /Zi /O2 /Ob1  -W3 -wd4311 -wd4146 -DUNIT_TESTING -D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE -D_WIN32_WINNT=0x0602 -DMSWIN -DINCLUDE_GENERATED_DECLARATIONS -ID:/a/neovim/neovim/.deps/usr/include/luajit-2.1 -ID:/a/neovim/neovim/.deps/usr/include -ID:/a/neovim/neovim/.deps/usr/include -ID:/a/neovim/neovim/build/src/nvim/auto -ID:/a/neovim/neovim/build/include -ID:/a/neovim/neovim/build/cmake.config -ID:/a/neovim/neovim/src -ID:/a/neovim/neovim/.deps/usr/include -ID:/a/neovim/neovim/.deps/usr/include -ID:/a/neovim/neovim/.deps/usr/include -ID:/a/neovim/neovim/.deps/usr/include -ID:/a/neovim/neovim/.deps/usr/include -ID:/a/neovim/neovim/.deps/usr/include -ID:/a/neovim/neovim/.deps/usr/include

   system vimrc file: "$VIM\sysinit.vim"
  fall-back for $VIM: "C:/Program Files (x86)/nvim/share/nvim"

Run :checkhealth for more info

延生阅读

分享到:

评论

目前只支持使用邮件参与评论。