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

set_query override json object to block.inner

Open
#477 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

I'm trying to override json object textobjects:

(object (_) @block.inner) @block.outer

@block.outer works, but @block.inner does not work. Not sure if I'm doing something wrong, or if this is not possible?

Perhaps I need to do something as below, but whenever I try to add something like that to my override, it complains that this kind of syntax is not valid.

(function_definition
  body: (compound_statement . "{" . (_) @_start @_end (_)? @_end . "}"
 (#make-range! "function.inner" @_start @_end)))

Would appreciate any guidance on this,
Thanks in advance!

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 set_query override path and compare how the two shown Tree-sitter query snippets are parsed and applied. Determine whether the @block.inner capture can be overridden for a JSON object and document or reproduce the expected behavior with a valid configuration.

Written by the indexing model from the issue text.

Assessment

Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.