chrisgrieser / nvim-various-textobjs

Bundle of more than 30 new text objects for Neovim.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

New Textobj: injected block

matthias-Q opened this issue · comments

Textobj requested

I have a lot of code blocks that are tracked by the injects.scm. For example SQL in R,Julia or Python. It would be nice the just select the injected code block.

Not sure is this is achievable at the moment because as far as I know there is not way to query the injected block using a tree-sitter query. But maybe I am wrong here.

Inner/Outer Difference

Not sure, maybe the direct parent?

Vimscript plugin already implementing the textobj

No response

Filetypes

all

Checklist

  • The textobj would be useful to more users than just me.
  • There is no lua plugin already implementing the textobj in an adequate manner.
  • I read the docs and there is no such textobj already.

I am not sure I understand. What exactly is requested? This plugin already has a text object for code blocks, though it does not use treesitter for that.

Generally, treesitter-based objects are great, but not the goal for this plugin, since there is already treesitter-textobjects for that.

Or is are injected code blocks something different here? I am not very familiar with python or R, so simply might not be understanding this correctly

Hmm,ok - even though I use this plugin I was always thinking that it uses tree-sitter. So my issue is that I have injected code blocks like this:
grafik

So I was thinking that a textobject would be nice that selects injected code section (in this example the SQL statement). However, it should be agnostic of the filetype and the parent node. I have created these injections for myself by matching on the function name (query_impala). So this is obviously not useful for other people. But generically selecting injected code blocks is in my opinion.

I can create this feature request in treesitter-textobjects if that makes more sense.

yeah, this plugin only uses pattern matching with some extras. It's mostly for use cases where treesitter does not make sense (e.g. the near-end-of-line textobj) or where treesitter textobj aren't there yet. (see for example #20)

Your suggestions makes more sense for treesitter-textobjects, yes