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

Define argument source with longer separator (multiple characters). #271

Open
DasOhmoff opened this issue Nov 11, 2021 · 2 comments
Open

Comments

@DasOhmoff
Copy link

DasOhmoff commented Nov 11, 2021

Hi. Thank you for your support.

I tried to implement a text object that is separated by logical operators, f.e the && operator. See following example (^ = cursor position, . = text object range):

   ..................
if(obj.Method().Bla() && condition)
          ^

My idea was to use the argument source, as it has the exact same functionality, the only difference is the separator (which is , instead of &&). I tried to extend the targets mapping through the following way:

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

But this does not seem to be working. I think the problem is that the separator is expected to be exactly a single character long.

How can I implement such a feature? It would be great if there was something like this that we could use, it would open many doors to create custom text operators.

@unphased
Copy link

I really wanted to implement logical statement text objects today, and this is holding me back. I was told in my topic #254 that these are regexes but I suspect they are not, so it's very strange that they're referred to as regexes. Let's look at the code to see what would need to change to make this work. I want logical statement text objects REAL bad right now.

@unphased
Copy link

OK from the code e.g. implementation of argument text object we can see that some simple regexes are built and used for matching, but the mechanism seems to be that of moving the cursor around (?) and testing that against these simple regexes.

It looks like following the template for plugins would be more suitable for something that requires multi character separators. But I worry about ending up having to test a ton of edgecases, and there are a ton of targets features that I wouldn't know how to begin properly testing. Hmm.

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

2 participants