Skip to content
Discussion options

You must be logged in to vote

How to do that in the most reliable and easy way?

I am afraid "reliable" and "easy" here are a bit at odds with each other.

The most reliable way would be to use tree-sitter based surrounding. For this particular case, it seems to require custom tree-sitter queries.

Here is what I've got mostly working:

  • Write custom tree-sitter query with two captures: one for the outside (text + left surrounding + right surrounding) and one for the inside (only text without surroundings). For this particular case, put the following code into '~/.config/nvim/after/queries/go/textobjects.scm':

    ;; extends
    (if_statement consequence: (block (statement_list) @if.inner )) @if.outer

    This query was created by…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@littlelinuxoid
Comment options

@echasnovski
Comment options

Answer selected by echasnovski
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
2 participants