Opening cpp and zig files will hang for a while.
Describe the bug
when open cpp or zig file will hang a while
To Reproduce
min config
vim.opt.rtp:append('path/to/nvim-treesitter/')
vim.opt.rtp:append('path/to/nvim-treesitter-textobjects/')
vim.opt.foldmethod = 'expr'
vim.opt.foldexpr = 'nvim_treesitter#foldexpr()'
require('nvim-treesitter.configs').setup({
highlight = {
enable = true,
},
textobjects = {
select = {
enable = true,
keymaps = {
['af'] = '@function.outer',
['if'] = '@function.inner',
['ac'] = '@class.outer',
['ic'] = '@class.inner',
},
},
},
})
- nvim --clean -u min_config.lua main.zig or main.cpp
Expected behavior
shouldn't hange a while
Output of :checkhealth nvim-treesitter
- WARNING `tree-sitter` executable not found (parser generator, only needed for :TSInstallFromGrammar, not required for :TSInstall)
- OK `node` found v20.8.0 (only needed for :TSInstallFromGrammar)
- OK `git` executable found.
- OK `cc` executable found. Selected from { vim.NIL, "cc", "gcc", "clang", "cl", "zig" }
Version: cc (GCC) 13.2.1 20230801
- OK Neovim was compiled with tree-sitter runtime ABI version 14 (required >=13). Parsers must be compatible with runtime ABI.
OS Info:
{
machine = "x86_64",
release = "6.5.7-arch1-1",
sysname = "Linux",
version = "#1 SMP PREEMPT_DYNAMIC Tue, 10 Oct 2023 21:10:21 +0000"
} ~
Parser/Features H L F I J
- bash ✓ ✓ ✓ . x
- c ✓ ✓ ✓ ✓ ✓
- cpp ✓ ✓ ✓ ✓ ✓
- css ✓ . ✓ ✓ ✓
- diff ✓ . . . .
- dockerfile ✓ . . . ✓
- go ✓ ✓ ✓ ✓ ✓
- gomod ✓ . . . ✓
- gosum ✓ . . . .
- gowork ✓ . . . ✓
- graphql ✓ . . ✓ ✓
- html ✓ ✓ ✓ ✓ ✓
- javascript ✓ ✓ ✓ ✓ ✓
- json ✓ ✓ ✓ ✓ .
- jsonc ✓ ✓ ✓ ✓ ✓
- lua ✓ ✓ ✓ ✓ ✓
- markdown ✓ . ✓ ✓ ✓
- markdown_inline ✓ . . . ✓
- proto ✓ . ✓ . .
- python ✓ ✓ ✓ ✓ ✓
- query ✓ ✓ ✓ ✓ ✓
- rust ✓ ✓ ✓ ✓ ✓
- scss ✓ . ✓ ✓ .
- sql ✓ . . ✓ ✓
- tsx ✓ ✓ ✓ ✓ ✓
- typescript ✓ ✓ ✓ ✓ ✓
- vim ✓ ✓ ✓ . ✓
- vimdoc ✓ . . . ✓
- 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} ~
The following errors have been detected: ~
- ERROR bash(injections): /usr/share/nvim/runtime/lua/vim/treesitter/query.lua:248: Query error at 9:4. Invalid node type "heredoc_end":
(heredoc_end) @injection.language)
^
bash(injections) is concatenated from the following files:
| [ERROR]:"/home/mw/.local/share/nvim/lazy/nvim-treesitter/queries/bash/injections.scm", failed to load: /usr/share/nvim/runtime/lua/vim/treesitter/query.lua:248: Query error at
9:4. Invalid node type "heredoc_end":
(heredoc_end) @injection.language)
^
Output of nvim --version
:version
NVIM v0.10.0-dev-aa62579
Build type: RelWithDebInfo
LuaJIT 2.1.1696795921
Run ":verbose version" for more info
Additional context
https://github.com/nvim-treesitter/nvim-treesitter/assets/41671631/68eb4c0e-e800-4157-8979-1781115c1b88
Not sure how to debug this with only this information, at least the minimal_init.lua file is missing
update .some format is wrong .
I don't face any issue without textobjects, so probably a problem from there?
@clason can you move the issue to the textobjs repo?
Same issue here
Same issue here, turning textobjects off and zig files open instantly, but with textobjects on it's like a second wait first time opening the buffer
EDIT: Looking into it a bit further, this ONLY seems to be the case when the "select" module is enabled. All other textobjects modules run fine. What's even weirder is that these issues only seem to occur on my beefy Linux desktop workstation (AMD Ryxen Threadripper 2950X 32 cores, with 96GiB RAM), whereas everything is smooth on my Macbook M1 with 16 GiB RAM...
EDIT2: I also experience significant slowdown when saving large zig files (on all my computers), but only if treesitter is used as foldmethod. Have worked around this with an auto command that sets foldmethod to manual when in zig files. So folding, and textobjects/select seem to be the issue. I can submit profiles of nvim while loading/saving files if interested