vim-cucumber
vim-cucumber copied to clipboard
Adds js as ft, supporting cucumberjs.
@jbnicolai does this work? @tpope could this be added?
I tried something similar with my config with no luck. As I see it javascript syntax need a different regex expression to process step definitions. Would love to see javascript supported myself
I think that was my concern that I never got around to asking about. Can anyone else speak to this? Ruby and JS regexps are both Perl based so I wouldn't think it would be an automatic deal breaker.
I have played around a bit with this and I think the current regex expression doest pick up JS definitions as they end in a comma instead of a ) like in ruby:
Given('i define the step definition', () => {
// Some code
});
It wouldn't be too hard to add a second regex expression specifically for JS filetypes.
I have managed to get it to work on my side with a very dirty one but it doesn't work with step definitions that pass arguments like:
Given('i define the {string} step definition', (arg) => {
// Some code
});
I wonder does that work with ruby or it a limitation of the plugin? I only used JS myself.
The \%(|[^|]*|\s*\)\= part of the regexp is designed to match the Ruby equivalent of |arg1, arg2|. You'll need to do similar for JavaScript.
Here's a starting point for anyone brave enough to attempt:
let step_pattern = '\C^\s*\K\k*\>\s*(\=\s*\zs\S.\{-\}\ze\s*\%()\=\s*\%(do\|{\)\s*\%(|[^|]*|\s*\)\=\%($\|#\)\|YOUR JS VERSION HERE\%($\|//\)\)'
@tpope I would like to give this a go but I am completely greed when it comes to regex. Any chance you can recommend a website where I can try composing it with more immediate feedback? Tried https://regexr.com/ but it does seem to be liking the available expression - I am guessing it uses a different engine or something.
Vim has a pattern engine of its own design. I don't know of any websites, but a good starting point might be :help perl-patterns to tell you the differences between that and a more popular option.