nvim-treesitter / nvim-treesitter/nvim-treesitter-textobjects
Fails to select @function.inner when Treesitter encounters an error
Nobody has claimed this yet.
- Dominant language
- Tree-sitter Query
- Stars
- 2.8k
- Forks
- 271
- Avg merge
- 8d 8h
- Merged PRs (30d)
- 1
Description
Describe the bug
Sometimes Treesitter cannot parse a statement with complex grammar, thus producing an "ERROR" node in the syntax tree. Then @function.inner doesn't treat the current function as a function.
To Reproduce
A simple example:
#include <stdio.h>
#define def(type, name) type name
int main() {
def(int, a);
a = 5;
}
As you can see, I pass a type name (i.e. int) as a macro argument. And this is the syntax tree shown by :InspectTree:
If you type vif (under default configuration) then it selects nothing.
Expected behavior
Textobjects should include (ERROR) nodes in @function.inner.
Output of :checkhealth nvim-treesitter
nvim-treesitter: require("nvim-treesitter.health").check()
Installation ~
- WARNING
tree-sitter executable not found (parser generator, only needed for :TSInstallFromGrammar, not required for :TSInstall)
- OK
node found v22.12.0 (only needed for :TSInstallFromGrammar)
- OK
git executable found.
- OK
cc executable found. Selected from { vim.NIL, "cc", "gcc", "clang", "cl", "zig" }
Version: gcc (GCC) 13.3.0
- 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 = "5.15.153.1-microsoft-standard-WSL2",
sysname = "Linux",
version = "#1 SMP Fri Mar 29 23:14:13 UTC 2024"
} ~
Parser/Features H L F I J
- ada ✓ ✓ ✓ . ✓
- agda ✓ . ✓ . ✓
- angular ✓ ✓ ✓ ✓ ✓
- apex ✓ ✓ ✓ . ✓
- arduino ✓ ✓ ✓ ✓ ✓
- asm ✓ . . . ✓
- astro ✓ ✓ ✓ ✓ ✓
- authzed ✓ . . . ✓
- awk ✓ . . . ✓
- bash ✓ ✓ ✓ . ✓
- bass ✓ ✓ ✓ ✓ ✓
- beancount ✓ . ✓ . ✓
- bibtex ✓ . ✓ ✓ ✓
- bicep ✓ ✓ ✓ ✓ ✓
- bitbake ✓ ✓ ✓ ✓ ✓
- blueprint ✓ . . . ✓
- bp ✓ ✓ ✓ ✓ ✓
- c ✓ ✓ ✓ ✓ ✓
- c_sharp ✓ ✓ ✓ . ✓
- cairo ✓ ✓ ✓ ✓ ✓
- capnp ✓ ✓ ✓ ✓ ✓
- chatito ✓ ✓ ✓ ✓ ✓
- clojure ✓ ✓ ✓ . ✓
- cmake ✓ . ✓ ✓ ✓
- comment ✓ . . . .
- commonlisp ✓ ✓ ✓ . ✓
- cooklang ✓ . . . ✓
- corn ✓ ✓ ✓ ✓ ✓
- cpon ✓ ✓ ✓ ✓ ✓
- cpp ✓ ✓ ✓ ✓ ✓
- css ✓ . ✓ ✓ ✓
- csv ✓ . . . .
- cuda ✓ ✓ ✓ ✓ ✓
- cue ✓ ✓ ✓ ✓ ✓
- cylc ✓ . ✓ ✓ ✓
- d ✓ ✓ ✓ ✓ ✓
- dart ✓ ✓ ✓ ✓ ✓
- desktop ✓ . ✓ . ✓
- devicetree ✓ ✓ ✓ ✓ ✓
- dhall ✓ . ✓ . ✓
- diff ✓ . ✓ . ✓
- disassembly ✓ . . . ✓
- djot ✓ ✓ ✓ ✓ ✓
- dockerfile ✓ . . . ✓
- dot ✓ . . ✓ ✓
- doxygen ✓ . . ✓ ✓
- dtd ✓ ✓ ✓ . ✓
- earthfile ✓ . . . ✓
- ebnf ✓ . . . ✓
- editorconfig ✓ . ✓ . ✓
- eds ✓ . ✓ . .
- eex ✓ . . . ✓
- elixir ✓ ✓ ✓ ✓ ✓
- elm ✓ . ✓ . ✓
- elsa ✓ ✓ ✓ ✓ ✓
- elvish ✓ . . . ✓
- embedded_template ✓ . . . ✓
- erlang ✓ . ✓ . ✓
- facility ✓ . ✓ ✓ ✓
- faust ✓ . . . ✓
- fennel ✓ ✓ ✓ . ✓
- fidl ✓ . ✓ . ✓
- firrtl ✓ ✓ ✓ ✓ ✓
- fish ✓ ✓ ✓ ✓ ✓
- foam ✓ ✓ ✓ ✓ ✓
- forth ✓ ✓ ✓ ✓ ✓
- fortran ✓ . ✓ ✓ ✓
- fsh ✓ . . . ✓
- fsharp ✓ . . . ✓
- func ✓ . . . ✓
- fusion ✓ ✓ ✓ ✓ ✓
- gap ✓ ✓ ✓ . ✓
- gaptst ✓ . ✓ . ✓
- gdscript ✓ ✓ ✓ ✓ ✓
- gdshader ✓ . . . ✓
- git_config ✓ . ✓ . ✓
- git_rebase ✓ . . . ✓
- gitattributes ✓ ✓ . . ✓
- gitcommit ✓ . . . ✓
- gitignore ✓ . . . ✓
- gleam ✓ ✓ ✓ ✓ ✓
- glimmer ✓ ✓ ✓ ✓ ✓
- glimmer_javascript ✓ ✓ . ✓ ✓
- glimmer_typescript ✓ . . ✓ ✓
- glsl ✓ ✓ ✓ ✓ ✓
- gn ✓ ✓ ✓ ✓ ✓
- gnuplot ✓ . . . ✓
- go ✓ ✓ ✓ ✓ ✓
- goctl ✓ . ✓ ✓ ✓
- godot_resource ✓ ✓ ✓ . ✓
- gomod ✓ . . . ✓
- gosum ✓ . . . .
- gotmpl ✓ ✓ ✓ . ✓
- gowork ✓ . . . ✓
- gpg ✓ . . . ✓
- graphql ✓ . . ✓ ✓
- gren ✓ . . . ✓
- groovy ✓ ✓ ✓ ✓ ✓
- gstlaunch ✓ . . . .
- hack ✓ . . . ✓
- hare ✓ ✓ ✓ ✓ ✓
- haskell ✓ ✓ ✓ . ✓
- haskell_persistent ✓ . ✓ . .
- hcl ✓ . ✓ ✓ ✓
- heex ✓ ✓ ✓ ✓ ✓
- helm ✓ ✓ ✓ . ✓
- hjson ✓ ✓ ✓ ✓ ✓
- hlsl ✓ ✓ ✓ ✓ ✓
- hlsplaylist ✓ . . . ✓
- hocon ✓ . ✓ . ✓
- hoon ✓ ✓ ✓ . ✓
- html ✓ ✓ ✓ ✓ ✓
- htmldjango ✓ . ✓ ✓ ✓
- http ✓ . . . ✓
- hurl ✓ . ✓ ✓ ✓
- hyprlang ✓ . ✓ ✓ ✓
- idl ✓ . . ✓ ✓
- ini ✓ . ✓ . ✓
- inko ✓ ✓ ✓ ✓ ✓
- ispc ✓ ✓ ✓ ✓ ✓
- janet_simple ✓ ✓ ✓ . ✓
- java ✓ ✓ ✓ ✓ ✓
- javascript ✓ ✓ ✓ ✓ ✓
- jq ✓ ✓ . . ✓
- jsdoc ✓ . . . .
- json ✓ ✓ ✓ ✓ .
- json5 ✓ . . . ✓
- jsonc ✓ ✓ ✓ ✓ ✓
- jsonnet ✓ ✓ ✓ . ✓
- julia ✓ ✓ ✓ ✓ ✓
- just ✓ ✓ ✓ ✓ ✓
- kconfig ✓ ✓ ✓ ✓ ✓
- kdl ✓ ✓ ✓ ✓ ✓
- kotlin ✓ ✓ ✓ . ✓
- koto ✓ ✓ ✓ . ✓
- kusto ✓ . . . ✓
- lalrpop ✓ ✓ ✓ . ✓
- ledger ✓ . ✓ ✓ ✓
- leo ✓ . . ✓ ✓
- linkerscript ✓ ✓ ✓ ✓ ✓
- liquid ✓ . . . ✓
- liquidsoap ✓ ✓ ✓ ✓ ✓
- llvm ✓ . . . ✓
- lua ✓ ✓ ✓ ✓ ✓
- luadoc ✓ . . . .
- luap ✓ . . . .
- luau ✓ ✓ ✓ ✓ ✓
- m68k ✓ ✓ ✓ . ✓
- make ✓ . ✓ . ✓
- markdown ✓ . ✓ ✓ ✓
- markdown_inline ✓ . . . ✓
- matlab ✓ ✓ ✓ ✓ ✓
- menhir ✓ . . . ✓
- mermaid ✓ . ✓ ✓ ✓
- meson ✓ . ✓ ✓ ✓
- muttrc ✓ . . . ✓
- nasm ✓ . . . ✓
- nginx ✓ . ✓ . ✓
- nickel ✓ . . ✓ ✓
- nim ✓ ✓ ✓ . ✓
- nim_format_string ✓ . . . ✓
- ninja ✓ . ✓ ✓ ✓
- nix ✓ ✓ ✓ ✓ ✓
- norg . . . . .
- nqc ✓ ✓ ✓ ✓ ✓
- nu ✓ . . ✓ ✓
- objc ✓ ✓ ✓ ✓ ✓
- objdump ✓ . . . ✓
- ocaml ✓ ✓ ✓ ✓ ✓
- ocaml_interface ✓ ✓ ✓ ✓ ✓
- odin ✓ ✓ ✓ ✓ ✓
- org . . . . .
- pascal ✓ ✓ ✓ ✓ ✓
- passwd ✓ . . . .
- pem ✓ . ✓ . ✓
- perl ✓ . ✓ . ✓
- php ✓ ✓ ✓ ✓ ✓
- php_only ✓ ✓ ✓ ✓ ✓
- phpdoc ✓ . . . .
- pioasm ✓ . . . ✓
- po ✓ . ✓ . ✓
- pod ✓ . . . .
- poe_filter ✓ . ✓ ✓ ✓
- pony ✓ ✓ ✓ ✓ ✓
- powershell ✓ ✓ ✓ ✓ ✓
- printf ✓ . . . .
- prisma ✓ . ✓ . ✓
- problog ✓ . ✓ ✓ ✓
- prolog ✓ . ✓ ✓ ✓
- promql ✓ . . . ✓
- properties ✓ ✓ . . ✓
- proto ✓ . ✓ ✓ ✓
- prql ✓ . . . ✓
- psv ✓ . . . .
- pug ✓ . . . ✓
- puppet ✓ ✓ ✓ ✓ ✓
- purescript ✓ ✓ . . ✓
- pymanifest ✓ . . . ✓
- python ✓ ✓ ✓ ✓ ✓
- ql ✓ ✓ ✓ ✓ ✓
- qmldir ✓ . . . ✓
- qmljs ✓ . ✓ . ✓
- query ✓ ✓ ✓ ✓ ✓
- r ✓ ✓ . ✓ ✓
- racket ✓ . ✓ . ✓
- ralph ✓ . . . ✓
- rasi ✓ ✓ ✓ ✓ ✓
- rbs ✓ . ✓ ✓ ✓
- re2c ✓ ✓ ✓ ✓ ✓
- readline ✓ . ✓ ✓ ✓
- regex ✓ . . . .
- rego ✓ . . . ✓
- requirements ✓ . . . ✓
- rescript ✓ ✓ ✓ ✓ ✓
- rnoweb ✓ . ✓ . ✓
- robot ✓ . ✓ ✓ ✓
- robots ✓ . . . ✓
- roc ✓ ✓ . . ✓
- ron ✓ ✓ ✓ ✓ ✓
- rst ✓ ✓ . . ✓
- ruby ✓ ✓ ✓ ✓ ✓
- runescript ✓ . . . ✓
- rust ✓ ✓ ✓ ✓ ✓
- scala ✓ ✓ ✓ . ✓
- scheme ✓ . ✓ . ✓
- scss ✓ . ✓ ✓ ✓
- sflog ✓ . . . .
- slang ✓ ✓ ✓ ✓ ✓
- slint ✓ ✓ ✓ ✓ ✓
- smali ✓ ✓ ✓ ✓ ✓
- smithy ✓ . . . ✓
- snakemake ✓ ✓ ✓ ✓ ✓
- solidity ✓ . ✓ . ✓
- soql ✓ . . . .
- sosl ✓ . . . .
- sourcepawn ✓ ✓ . . ✓
- sparql ✓ ✓ ✓ ✓ ✓
- sql ✓ . . ✓ ✓
- squirrel ✓ ✓ ✓ ✓ ✓
- ssh_config ✓ ✓ ✓ ✓ ✓
- starlark ✓ ✓ ✓ ✓ ✓
- strace ✓ . . . ✓
- styled ✓ . ✓ ✓ ✓
- supercollider ✓ ✓ ✓ ✓ ✓
- superhtml ✓ . . . ✓
- surface ✓ . ✓ ✓ ✓
- svelte ✓ ✓ ✓ ✓ ✓
- sway ✓ ✓ ✓ ✓ ✓
- sxhkdrc ✓ . ✓ . ✓
- systemtap ✓ ✓ ✓ . ✓
- t32 ✓ ✓ ✓ ✓ ✓
- tablegen ✓ ✓ ✓ ✓ ✓
- tact ✓ ✓ ✓ ✓ ✓
- tcl ✓ . ✓ ✓ ✓
- templ ✓ . ✓ . ✓
- terraform ✓ . ✓ ✓ ✓
- textproto ✓ . ✓ ✓ ✓
- thrift ✓ ✓ ✓ ✓ ✓
- tiger ✓ ✓ ✓ ✓ ✓
- tlaplus ✓ ✓ ✓ . ✓
- tmux ✓ . . . ✓
- todotxt ✓ . . . .
- toml ✓ ✓ ✓ ✓ ✓
- tsv ✓ . . . .
- tsx ✓ ✓ ✓ ✓ ✓
- turtle ✓ ✓ ✓ ✓ ✓
- twig ✓ . . . ✓
- typescript ✓ ✓ ✓ ✓ ✓
- typespec ✓ . . ✓ ✓
- typoscript ✓ . ✓ ✓ ✓
- typst ✓ . ✓ ✓ ✓
- udev ✓ ✓ . . ✓
- ungrammar ✓ ✓ ✓ ✓ ✓
- usd ✓ ✓ ✓ ✓ ✓
- uxntal ✓ ✓ ✓ ✓ ✓
- v ✓ ✓ ✓ ✓ ✓
- vala ✓ . ✓ . ✓
- vento ✓ . . . ✓
- verilog ✓ . ✓ . ✓
- vhdl ✓ . ✓ . ✓
- vhs ✓ . . . ✓
- vim ✓ ✓ ✓ . ✓
- vimdoc ✓ . . . ✓
- vrl ✓ ✓ ✓ ✓ ✓
- vue ✓ . ✓ ✓ ✓
- wgsl ✓ . ✓ ✓ ✓
- wgsl_bevy ✓ . ✓ ✓ .
- wing ✓ ✓ ✓ . ✓
- wit ✓ . ✓ . ✓
- xcompose ✓ ✓ . . ✓
- xml ✓ ✓ ✓ ✓ ✓
- xresources ✓ ✓ ✓ . ✓
- yaml ✓ ✓ ✓ ✓ ✓
- yang ✓ . ✓ ✓ ✓
- yuck ✓ ✓ ✓ ✓ ✓
- zathurarc ✓ . . . ✓
- zig ✓ ✓ ✓ ✓ ✓
- ziggy ✓ . . ✓ .
- ziggy_schema ✓ . . ✓ .
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.10.2
Build type: Release
LuaJIT 2.1.1713773202
Run "nvim -V1 -v" for more info
Additional context
Add any other context about the problem here.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the C example and inspect its syntax tree with :InspectTree, then compare the behavior of the default vif selection for @function.inner. Trace the textobject query or entry point responsible for function.inner and verify that the completed change selects the function body even when the tree contains an ERROR node.
Written by the indexing model from the issue text.
Assessment
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100