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

Opening cpp and zig files will hang for a while. #507

Open
glepnir opened this issue Oct 15, 2023 · 5 comments
Open

Opening cpp and zig files will hang for a while. #507

glepnir opened this issue Oct 15, 2023 · 5 comments
Labels
bug Something isn't working

Comments

@glepnir
Copy link

glepnir commented Oct 15, 2023

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',
      },
    },
  },
})
  1. 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

2023-10-15.15-27-59.mp4
@glepnir glepnir added the bug Something isn't working label Oct 15, 2023
@lucario387
Copy link
Member

Not sure how to debug this with only this information, at least the minimal_init.lua file is missing

@glepnir
Copy link
Author

glepnir commented Oct 15, 2023

update .some format is wrong .

@lucario387
Copy link
Member

I don't face any issue without textobjects, so probably a problem from there?

@clason can you move the issue to the textobjs repo?

@clason clason transferred this issue from nvim-treesitter/nvim-treesitter Oct 15, 2023
@lothran

This comment was marked as duplicate.

@maxbol
Copy link

maxbol commented May 27, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants