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

argument textobjects on braces #254

Closed
unphased opened this issue Aug 11, 2020 · 6 comments
Closed

argument textobjects on braces #254

unphased opened this issue Aug 11, 2020 · 6 comments

Comments

@unphased
Copy link

unphased commented Aug 11, 2020

When working with javascript something like this:

const opts = { type: "select", ...enqOpts };

I'd like a quick way to e.g. delete the entire type: "select", part, and if the brackets were parens, this would work fine.

It looks possible by extending, I will report back if I can make it work.

@unphased
Copy link
Author

unphased commented Aug 11, 2020

Sorry @wellle I'm thoroughly perplexed by the meaning of [] in:

'a': {'argument': [{'o': '[([]', 'c': '[])]', 's': ','}]},

Hope you can explain what it represents.

@unphased
Copy link
Author

Furthermore, upon trying

 autocmd User targets#mappings#user call targets#mappings#extend({
		\ 'a': {'argument': [{'o': '{[([]', 'c': '[])]}', 's': ','}]},
		\ })

All this did was render the a functionality completely inoperable.

@wellle
Copy link
Owner

wellle commented Aug 11, 2020

@unphased: Thanks for opening this issue. I can see how this is confusing. The argument settings o and c are actually regexes, so for example [{[] means { or [. It's important to keep [ and ] as the first and last character so this is a valid regex. And in order to include a [ or ] within the range it needs to be the last or first character respectively within the surrounding [].

Please try this version:

autocmd User targets#mappings#user call targets#mappings#extend({
		\ 'a': {'argument': [{'o': '[{([]', 'c': '[])}]', 's': ','}]},
		\ })

We used to have this better documented, but I removed that part when refactoring the settings. See https://github.com/wellle/targets.vim/tree/v0.4.6#gtargets_argopening-and-gtargets_argclosing

I guess we should bring back that documentation, it even included your use case as an example. So let me know if the suggestion above works for you, but please keep this issue open as a reminder to improve the documentation.

@unphased
Copy link
Author

unphased commented Aug 11, 2020

Ah, I wish I thought to treat them as regexes. Obvious only in hindsight. Thanks! Will try that out.

@eight04
Copy link

eight04 commented Dec 7, 2021

Does #267 fix this?

@unphased
Copy link
Author

unphased commented Dec 7, 2021

Does #267 fix this?

Yup. I think @wellle answer gave me more of what I needed though. So I am closing this. My custom definition for a also includes ; as separator. It's neat.

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

No branches or pull requests

3 participants