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

Adds js as ft, supporting cucumberjs. #37

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jbnicolai
Copy link

Review on Reviewable

@christopher-francisco
Copy link

@jbnicolai does this work? @tpope could this be added?

@ArtemSmaznov
Copy link

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

@tpope
Copy link
Owner

tpope commented Feb 23, 2021

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.

@ArtemSmaznov
Copy link

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.

@tpope
Copy link
Owner

tpope commented Feb 23, 2021

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\%($\|//\)\)'

@ArtemSmaznov
Copy link

@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.

@tpope
Copy link
Owner

tpope commented Mar 17, 2021

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.

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

Successfully merging this pull request may close these issues.

None yet

4 participants