nvim-treesitter-textobjects
nvim-treesitter-textobjects copied to clipboard
Neovim hangs when opening zig files with treesitter-textobjects installed
When loading zig files with textobject keybindings configured, neovim hangs and uses 100% cpu. Neovim doesn't even get to a point where it displays a status line when loading a file passed on the command line.
To Reproduce Load a zig file with the provided vimrc.
Expected behavior Neovim should load, and display the file.
Output of :checkhealth nvim_treesitter
nvim_treesitter: health#nvim_treesitter#check
========================================================================
## Installation
- WARNING: `tree-sitter` executable not found (parser generator, only needed for :TSInstallFromGrammar, not required for :TSInstall)
- WARNING: `node` executable not found (only needed for :TSInstallFromGrammar, not required for :TSInstall)
- OK: `git` executable found.
- OK: `cc` executable found. Selected from { vim.NIL, "cc", "gcc", "clang", "cl", "zig" }
Version: cc (Alpine 11.2.1_git20211128) 11.2.1 20211128
- OK: Neovim was compiled with tree-sitter runtime ABI version 13 (required >=13). Parsers must be compatible with runtime ABI.
## Parser/Features H L F I J
- zig _ . _ _ _
Legend: H[ighlight], L[ocals], F[olds], I[ndents], In[j]ections
+) multiple parsers found, only one will be used
x) errors found in the query, try to run :TSUpdate {lang}
Output of nvim --version
NVIM v0.6.0
Build type: MinSizeRel
LuaJIT 2.1.0-beta3
Compiled by buildozer@build-edge-x86_64
Features: +acl +iconv +tui
See ":help feature-compile"
system vimrc file: "$VIM/sysinit.vim"
fall-back for $VIM: "/usr/share/nvim"
Run :checkhealth for more info
Additional context
I had this issue on an arch linux system, and was able to reproduce it in a alpine (edge) container. All the outputs I've provided are from the container.
The minimal vimrc I was able to reproduce this with:
call plug#begin('~/.config/nvim/plugged')
Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}
Plug 'nvim-treesitter/nvim-treesitter-textobjects'
call plug#end()
lua << EOS
require'nvim-treesitter.configs'.setup {
ensure_installed = { "zig" },
highlight = { enable = true },
textobjects = {
select = {
enable = true,
keymaps = {
-- Any of these will cause neovim to hang
["af"] = "@function.outer",
["if"] = "@function.inner",
["ac"] = "@class.outer",
["ic"] = "@class.inner",
-- But this doesn't cause neovim to hang
["iF"] = {
c = "(function_definition) @function",
},
},
},
},
}
EOS
Did you try the newest nightly? A fix for this problem has landed in tree-sitter. You can also build 0.6 release with newest tree-sitter master.
When the tree-sitter patch will in the neovim built?
@nanozuki it's already there, but you need to use nightly or wait for a new release of neovim if you wan to use stable neovim.
I just built neovim-git from the aur, and it still has this issue. I also tested the last nightly appimage, and it loaded the file eventually, but hung for a few seconds in the process. It didn't hang when I removed the problematic lines indicated in my minimal vimrc.
This is the output from nvim nvim --version
with the aur build.
NVIM v0.7.0-dev+761-g0d7a97224
Build type: RelWithDebInfo
LuaJIT 2.0.5
Compilation: /usr/bin/cc -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -DNVIM_TS_HAS_SET_MATCH_LIMIT -O2 -g -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/home/aren/.cache/paru/clone/neovim-git/src/build/config -I/home/aren/.cache/paru/clone/neovim-git/src/neovim-git/src -I/usr/include -I/home/aren/.cache/paru/clone/neovim-git/src/build/src/nvim/auto -I/home/aren/.cache/paru/clone/neovim-git/src/build/include
Compiled by aren@xeez
Features: +acl +iconv +tui
See ":help feature-compile"
system vimrc file: "$VIM/sysinit.vim"
fall-back for $VIM: "/usr/share/nvim"
Run :checkhealth for more info
And from the nightly image I tested.
NVIM v0.7.0-dev+761-g0d7a97224
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Compilation: /usr/bin/gcc-11 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNVIM_TS_HAS_SET_MATCH_LIMIT -O2 -g -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=always -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/home/runner/work/neovim/neovim/build/config -I/home/runner/work/neovim/neovim/src -I/home/runner/work/neovim/neovim/.deps/usr/include -I/usr/include -I/home/runner/work/neovim/neovim/build/src/nvim/auto -I/home/runner/work/neovim/neovim/build/include
Compiled by runner@fv-az32-596
Features: +acl +iconv +tui
See ":help feature-compile"
system vimrc file: "$VIM/sysinit.vim"
fall-back for $VIM: "
/home/runner/work/neovim/neovim/build/nvim.AppDir/usr/share/nvim"
@ArenM make sure to also install treesitter-git, or whatever the package name is to install the latest version of treesitter.
It had to be tree-sitter master as the fix is not yet in a release.
Building tresitter seems to have made things better, but it seems like there's still something strange going on.
Neovim still hangs, but only for a few seconds now. It doesn't hang when I comment out the lines I pointed out in my initial report.
I also tested the nightly appimage, and it did the same thing. That should include a good version of treesitter right?
I'm closing the issue as it seems to be fixed, but feel free to re-open if you still have issues!