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

Zig file takes a long time to open

Open
#461 21 comments 0 reactions 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 I open a zig file with this extension enabled it takes 3 seconds on my machine to start it

To Reproduce
I made a minimal config to reproduce:
git clone https://github.com/lnc3l0t/treesitter-textobjects-issue /tmp/nvim; cd /tmp/nvim; . launch.sh
It contains:

  • launch.sh script which clone nvim-treesitter and nvim-treesitter-textobjects, installs the zig parser, launches neovim and benchmarks it.
  • init.lua minimal neovim config that sets up package.path and nvim-treesitter.config
  • main.zig a minimal zig file to open

Expected behavior
It should open like any other filetypes but on my machine the benchmarks take around 3 seconds:

Time

real 0m3.181s
user 0m3.159s
sys 0m0.024s

Hyperfine
Benchmark 1: nvim --clean -u init.lua main.zig -c "q"
Time (mean ± σ): 3.202 s ± 0.007 s [User: 3.181 s, System: 0.019 s]
Range (min … max): 3.189 s … 3.209 s 10 runs

Output of :checkhealth nvim-treesitter

==============================================================================
nvim-treesitter: require("nvim-treesitter.health").check()
Installation ~

  • OK tree-sitter found 0.20.8 (parser generator, only needed for :TSInstallFromGrammar)
  • OK node found v20.2.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.1.1 20230429
  • 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.3.5-arch1-1",
    sysname = "Linux",
    version = "#1 SMP PREEMPT_DYNAMIC Tue, 30 May 2023 13:44:01 +0000"
    } ~
    Parser/Features H L F I J
  • bash ✓ ✓ ✓ . ✓
  • c ✓ ✓ ✓ ✓ ✓
  • cmake ✓ . ✓ . .
  • cpp ✓ ✓ ✓ ✓ ✓
  • dart ✓ ✓ ✓ ✓ ✓
  • fish ✓ ✓ ✓ ✓ ✓
  • git_config ✓ . . . .
  • git_rebase ✓ . . . ✓
  • gitattributes ✓ . . . ✓
  • gitcommit ✓ . . . ✓
  • gitignore ✓ . . . .
  • ini ✓ . ✓ . .
  • javascript ✓ ✓ ✓ ✓ ✓
  • json ✓ ✓ ✓ ✓ .
  • jsonc ✓ ✓ ✓ ✓ ✓
  • lua ✓ ✓ ✓ ✓ ✓
  • make ✓ . ✓ . ✓
  • markdown ✓ . ✓ ✓ ✓
  • nix ✓ ✓ ✓ . ✓
  • python ✓ ✓ ✓ ✓ ✓
  • query ✓ ✓ ✓ ✓ ✓
  • rust ✓ ✓ ✓ ✓ ✓
  • scss ✓ . ✓ ✓ .
  • teal ✓ ✓ ✓ ✓ ✓
  • toml ✓ ✓ ✓ ✓ ✓
  • vhs ✓ . . . .
  • vim ✓ ✓ ✓ . ✓
  • vimdoc ✓ . . . ✓
  • yaml ✓ ✓ ✓ ✓ ✓
  • yuck ✓ ✓ ✓ ✓ ✓
  • 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 Tried with both master and stable

NVIM v0.10.0-dev-449+gcc4169777
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Compilation: /usr/bin/gcc-10 -O2 -g -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wvla -Wdouble-promotion -Wmissing-noreturn -Wmissing-format-attribute -Wmissing-prototypes -fno-common -Wno-unused-result -Wimplicit-fallthrough -fdiagnostics-color=always -fstack-protector-strong -DUNIT_TESTING -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_TS_HAS_SET_MAX_START_DEPTH -I/__w/neovim/neovim/.deps/usr/include/luajit-2.1 -I/usr/include -I/__w/neovim/neovim/.deps/usr/include -I/__w/neovim/neovim/build/src/nvim/auto -I/__w/neovim/neovim/build/include -I/__w/neovim/neovim/build/cmake.config -I/__w/neovim/neovim/src -I/usr/include -I/__w/neovim/neovim/.deps/usr/include -I/__w/neovim/neovim/.deps/usr/include -I/__w/neovim/neovim/.deps/usr/include -I/__w/neovim/neovim/.deps/usr/include -I/__w/neovim/neovim/.deps/usr/include -I/__w/neovim/neovim/.deps/usr/include
   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/__w/neovim/neovim/build/nvim.AppDir/usr/share/nvim"
--------------------------------------------------------------------------------------------------------------------
NVIM v0.9.1
Build type: Release
LuaJIT 2.1.0-beta3

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/__w/neovim/neovim/build/nvim.AppDir/usr/share/nvim"

Additional context
I checked for issues in these repository and in nvim-treesitter regarding zig but I couldn't find anything related.

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

Start with the linked minimal reproduction's launch.sh and init.lua, then run its benchmark to confirm the delay when opening main.zig. Compare startup timing with other filetypes and inspect the Zig-related configuration enabled by nvim-treesitter-textobjects. Done means identifying the source of the Zig-specific startup cost and demonstrating that the benchmark improves without breaking the existing setup.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.