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

Motion around node

Open
#190 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

It would be very convenient to have in addition to init_selection a similar command that works in operator-pending mode, i.e., something like "around node" or "an", so that one can use "dan", "yan" etc.

Currently the same functionality can be done by first invoking the init_selection and then using the operator, but in my opinion around operator can be useful as well. There is also a treesitter-textobjects, that allows around motions, but only for selected tags in selected languages, whereas "around node" should be quite general.

I have tried to use the public api of treesitter to write this functionality, but failed, perhaps due to my lack of knowledge. If there is a way, maybe it can be added to the documentation, and if not I believe that this can easily be done using the inner workings of nvim-treesitter.

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 by reading the existing init_selection behavior and the public Tree-sitter API, then compare it with the inner workings of nvim-treesitter-textobjects. Determine how an around-node motion should work in operator-pending mode and verify that commands such as dan and yan provide the requested behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
neovim
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.