Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Textobj: item in list "," #58

Closed
3 tasks done
gerazov opened this issue Oct 25, 2023 · 6 comments
Closed
3 tasks done

New Textobj: item in list "," #58

gerazov opened this issue Oct 25, 2023 · 6 comments

Comments

@gerazov
Copy link

gerazov commented Oct 25, 2023

Textobj requested

Select item in a list of items separated with , and bound by brackets or newlines, e.g:

a = [1, 2, 3, 4]
b = [
    1, 2, 3, 4
    ]

This is similar to argument, but argument is limited to ().

Inner/Outer Difference

Inner leaves the ,
Outer includes the preceding (following if first item) ,

Vimscript plugin already implementing the textobj

https://github.com/wellle/targets.vim

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.
@chrisgrieser
Copy link
Owner

chrisgrieser commented Oct 26, 2023

In most languages (e.g., lua), you can use the argument textobj from treesitter-textobjects for that already. If your language does not support that, I think it'd make more sense to make a FR there instead of re-implementing the same textobj again here

@chrisgrieser chrisgrieser closed this as not planned Won't fix, can't repro, duplicate, stale Oct 26, 2023
@gerazov
Copy link
Author

gerazov commented Oct 26, 2023

Well not really, or at least as much as I know - the argument object works only for arguments in a function call, i.e. it'll work only if the items are bounded by ( ) and not in the case above.

@chrisgrieser
Copy link
Owner

chrisgrieser commented Oct 26, 2023

as I said, is some languages like in lua, it also works for array elements. If it does not work in your language, it'd therefore make more sense to make a FR there instead of re-implementing the same textobj again here

@gerazov
Copy link
Author

gerazov commented Oct 26, 2023

Oh you're right - it does work 😅 my bad - I thought I tested it ...

@gerazov
Copy link
Author

gerazov commented Nov 5, 2023

It would be useful for pure text, e.g.

This is a list of items in: rst, md, txt, text, mail files. 

Here the treesitter solution doesn't work. Also for comments in code scripts that list stuff.

Currently I have it working through https://github.com/wellle/targets.vim, it would nice to have it in a nvim plugin.

@chrisgrieser
Copy link
Owner

Like a sub-sentence? Hmm. I can see a lot of potential edge cases for this (where does the first element in the list start, what about decimal commas and thousand separators, etc.)

Could you open a new issue for it since it's somewhat different, and also detail how exactly such a text object should behave?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants