Open jdsutherland opened 3 years ago
No, that's fine -- the definitions are all attempted, and the "smallest" match wins. The problem is that the pattern is surrounded by double-quotes, and those evaluate backslashes. If you echo b:sideways_definitions[1]
, you'll get:
{'skip_syntax': [], 'end': '''', 'brackets': ['', ''], 'start': 'v<class:s?''', 'delimited_by_whitespace': 1}
And you can see the start pattern starts with v
instead of \v
. One option would be to use \\
in the double-quotes, another is to use single quotes and escape apostrophes by doubling them: '\v<class:\s?'''
. This is, admittedly, a bit obscure :). You could learn more details from :help string
and :help literal-string
.
I'm not sure if I it makes sense to keep this in the default definitions, since it's specific to the rails helper, and not a feature of ERB itself. Still, I guess it wouldn't be a practical problem, and it's true that most ERB is rails... Would you like to see this in the defaults, or are you happy to use this in your own override? If you'd like, you could create a PR with the change, and I can probably be persuaded to merge it.
I'm fine with having this be an override. I can imagine encountering a gem that use some variation of the name class
that I'd want to add in.
Thanks for clearing that up! I've learned some things that should useful for future changes. Actually the customization section in help covers this pretty well, sorry!
I find myself having the same problem constantly with classes in option hashes in ERB. I've gotten used to stopping myself from using this plugin's functionality in that one context, but it's a constant point of tiny friction
I tried using @jdsutherland implementation, then modifying it based on @AndrewRadev's response, but couldn't get it to work... I know it's an old issue but if anyone can help I would be really grateful 🙏
@pooriar I've added support to the repo in the eruby-classes branch. Could you try it out and see if the patterns in that form work?
It'd be nice if https://github.com/AndrewRadev/sideways.vim/pull/41 worked for option hashes in eruby:
I tried implementing this myself:
but the existing seemed to take precedence. I'm guessing the regex:
would have to negative lookahead for
class:
?