nvim-treesitter / nvim-treesitter/nvim-treesitter-textobjects

Opening cpp and zig files will hang for a while.

Open
#507 8 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Tree-sitter Query
Stars
2.8k
Forks
271
Avg merge
8d 8h
Merged PRs (30d)
1

Description

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

https://github.com/nvim-treesitter/nvim-treesitter/assets/41671631/68eb4c0e-e800-4157-8979-1781115c1b88

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce with min_config.lua by opening main.zig and main.cpp, then compare the startup path involving foldmethod=expr, nvim_treesitter#foldexpr(), highlighting, and textobjects. The issue names no source file or test; done means opening both files no longer hangs for a while, with a regression check added if the relevant path is identified.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, lua, zig
Domain
performance, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.