nvim-treesitter / nvim-treesitter-textobjects

Apache License 2.0
2.2k stars 200 forks source link

zig's `@function.inner` incorrectly includes curly braces #669

Closed MariaSolOs closed 3 months ago

MariaSolOs commented 3 months ago

Describe the bug When using a motion like cif (where if has been mapped to @function.inner in a zig file, the motion will also delete the function's curly braces. Note that this doesn't happen in other languages, like rust and TypeScript.

Expected behavior For @function.inner to exclude the curly braces in zig.

Output of :checkhealth nvim-treesitter

``` ============================================================================== nvim-treesitter: require("nvim-treesitter.health").check() Installation ~ - OK `tree-sitter` found 0.22.6 (parser generator, only needed for :TSInstallFromGrammar) - OK `node` found v18.12.0 (only needed for :TSInstallFromGrammar) - OK `git` executable found. - OK `cc` executable found. Selected from { vim.NIL, "cc", "gcc", "clang", "cl", "zig" } Version: Apple clang version 15.0.0 (clang-1500.3.9.4) - OK Neovim was compiled with tree-sitter runtime ABI version 14 (required >=13). Parsers must be compatible with runtime ABI. OS Info: { machine = "arm64", release = "23.6.0", sysname = "Darwin", version = "Darwin Kernel Version 23.6.0: Mon Jul 29 21:14:30 PDT 2024; root:xnu-10063.141.2~1/RELEASE_ARM64_T6000" } ~ Parser/Features H L F I J - bash ✓ ✓ ✓ . ✓ - c ✓ ✓ ✓ ✓ ✓ - cpp ✓ ✓ ✓ ✓ ✓ - css ✓ . ✓ ✓ ✓ - fish ✓ ✓ ✓ ✓ ✓ - gitcommit ✓ . . . ✓ - html ✓ ✓ ✓ ✓ ✓ - javascript ✓ ✓ ✓ ✓ ✓ - json ✓ ✓ ✓ ✓ . - json5 ✓ . . . ✓ - jsonc ✓ ✓ ✓ ✓ ✓ - lua ✓ ✓ ✓ ✓ ✓ - markdown ✓ . ✓ ✓ ✓ - markdown_inline ✓ . . . ✓ - python ✓ ✓ ✓ ✓ ✓ - query ✓ ✓ ✓ ✓ ✓ - regex ✓ . . . . - rust ✓ ✓ ✓ ✓ ✓ - scss ✓ . ✓ ✓ ✓ - toml ✓ ✓ ✓ ✓ ✓ - typescript ✓ ✓ ✓ ✓ ✓ - vim ✓ ✓ ✓ . ✓ - vimdoc ✓ . . . ✓ - yaml ✓ ✓ ✓ ✓ ✓ - 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.11.0-dev-596+g4e8efe002
Build type: RelWithDebInfo
LuaJIT 2.1.1720049189
kiyoon commented 3 months ago

Hola 👋

https://github.com/nvim-treesitter/nvim-treesitter-textobjects/blob/ca93cb2c34b67ab22d01976fc90bc95627a3317f/queries/c/textobjects.scm#L12-L22

I believe adding this kind of syntax with #make-range would solve the issue.