Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

neovim-git 缺少 tree-sitter parser 依赖 #3731

Open
someoneinjd opened this issue Mar 29, 2024 · 4 comments
Open

neovim-git 缺少 tree-sitter parser 依赖 #3731

someoneinjd opened this issue Mar 29, 2024 · 4 comments
Assignees

Comments

@someoneinjd
Copy link

问题类型 / Type of issues

  • 打包错误 / packaging error

受影响的软件包 / Affected packages

  • neovim-git

请在此补充说明。
Please describe in detail here.

neovim-git 在构建时指定了 USE_BUNDLE=OFF , 构建出来的 nvim 不含任何 treesitter parser,但 runtime 中许多配置都默认了 tree-sitter-lua / tree-sitter-bash / tree-sitter-c 等 parser 已经被安装,比如 ftplugin/lua.lua

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

这导致使用 nvim 打开对应文件时找不到 parser,报错如下

# nvim test.lua --clean
Error detected while processing BufNewFile Autocommands for "*":                                                                                           
Error executing lua callback: /usr/share/nvim/runtime/filetype.lua:35: Error executing lua: /usr/share/nvim/runtime/filetype.lua:36: BufNewFile Autocommand
s for "*"..FileType Autocommands for "*"..function <SNR>1_LoadFTPlugin[20]..script /usr/share/nvim/runtime/ftplugin/lua.lua: Vim(runtime):E5113: Error whil
e calling lua chunk: /usr/share/nvim/runtime/lua/vim/treesitter/language.lua:104: no parser for 'lua' language, see :help treesitter-parsers               
stack traceback:                                                                                                                                           
        [C]: in function 'error'                                                                                                                           
        /usr/share/nvim/runtime/lua/vim/treesitter/language.lua:104: in function 'add'                                                                     
        /usr/share/nvim/runtime/lua/vim/treesitter/languagetree.lua:111: in function 'new'                                                                 
        /usr/share/nvim/runtime/lua/vim/treesitter.lua:41: in function '_create_parser'                                                                    
        /usr/share/nvim/runtime/lua/vim/treesitter.lua:108: in function 'get_parser'                                                                       
        /usr/share/nvim/runtime/lua/vim/treesitter.lua:416: in function 'start'                                                                            
        /usr/share/nvim/runtime/ftplugin/lua.lua:2: in main chunk                                                                                          
        [C]: in function 'nvim_cmd'                                                                                                                        
        /usr/share/nvim/runtime/filetype.lua:36: in function </usr/share/nvim/runtime/filetype.lua:35>                                                     
        [C]: in function 'nvim_buf_call'                                                                                                                   
        /usr/share/nvim/runtime/filetype.lua:35: in function </usr/share/nvim/runtime/filetype.lua:10>                                                     
stack traceback:                                                                                                                                           
        [C]: in function 'nvim_cmd'                                                                                                                        
        /usr/share/nvim/runtime/filetype.lua:36: in function </usr/share/nvim/runtime/filetype.lua:35>                                                     
        [C]: in function 'nvim_buf_call'                                                                                                                   
        /usr/share/nvim/runtime/filetype.lua:35: in function </usr/share/nvim/runtime/filetype.lua:10>                                                     
stack traceback:                                                                                                                                           
        [C]: in function 'nvim_buf_call'                                                                                                                   
        /usr/share/nvim/runtime/filetype.lua:35: in function </usr/share/nvim/runtime/filetype.lua:10>

一种可能的解决方案是启用 tree-sitter parser 的 bundled 依赖,构建过程如下 (ref)

cmake -S cmake.deps -B .deps -G Ninja \
             -DCMAKE_BUILD_TYPE=RelWithDebInfo \
             -DCMAKE_INSTALL_PREFIX=/usr \
             -DUSE_BUNDLED=OFF \
             -DUSE_BUNDLED_TS_PARSERS=ON
cmake --build .deps
cmake -B build -G Ninja \
             -DCMAKE_BUILD_TYPE=RelWithDebInfo \
             -DCMAKE_INSTALL_PREFIX=/usr
cmake --build build
@SilverRainZ
Copy link
Member

是说 USE_BUNDLED=OFF 的情况下,nvim 会带上 nvim-tree-sitter 但不带上 tree-sitter-lua 之类的是么?感觉不太合理啊。

@someoneinjd
Copy link
Author

二者都不带,但 tree-sitter 会作为依赖被引入(tree-sitter-git),而 tree-sitter-lua 之类的 parser 没有。并且还有个小问题是按照目前 PKGBUILD 的构建流程,USE_BUNDLED=OFF 这一选项是没有用的,USE_BUNDLED 相关的变量都只在 cmake.deps 里面起作用,cmake 也会给出如下 warning

CMake Warning:
  Manually-specified variables were not used by the project:

    USE_BUNDLED

另外还想请问一下有没有成功复现问题描述里 nvim test.lua --clean 的 bug,也有可能是我这边环境配置出了问题。

@SilverRainZ
Copy link
Member

是的,我复现了。

简单搜索了一下,似乎 nightly 正处在一个默认启用 treesitter 的过渡阶段(也或者是 nightly 总是强制默认用 tree-sitter)。

总之官方不对这个问题提供支持:neovim/neovim#26746 (comment)

@someoneinjd
Copy link
Author

这个问题可以在打包的时候解决,也就是之前提到的构建时启用 parser 的 bundle,把默认启用的 vim / lua / c / markdown 等 parser 都给打包了,亲测有效,可以解决 bug。

或者也可以尝试添加对 tree-sitter-lua / vim / c 的依赖,不过不确定是否可以解决问题。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants