Giter VIP home page Giter VIP logo

vim-cucumber's Introduction

vim-cucumber

This is the development version of Vim's included runtime files for the Ruby acceptance testing framework Cucumber. It provides syntax highlighting, indenting, and some editing commands.

Commands

vim-cucumber provides commands to jump from steps to step definitions in feature files.

In normal mode, pressing [<C-d> or ]<C-d> on a step jumps to the corresponding step definition and replaces the current buffer. <C-W>d or <C-w><C-d> on a step jumps to its definition in a new split buffer and moves the cursor there. [d or ]d on a step opens the step definition in a new split buffer while maintaining the current cursor position.

Installation

Install using your favorite package manager, or use Vim's built-in package support:

mkdir -p ~/.vim/pack/tpope/start
cd ~/.vim/pack/tpope/start
git clone https://tpope.io/vim/cucumber.git

vim-cucumber's People

Contributors

mwilden avatar nbossard avatar p0deje avatar panozzaj avatar sofaking avatar tpope avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

vim-cucumber's Issues

Feature narrative block has no syntax hilighting

If you look at the screenshots at:

Or the original JBehave grammar at:

You will see that In order to, As a and I want to have special meaning in the context of the Feature: block.

It would be nice to get syntax highlighting on the In order, As a, and I want parts.


Note that I'm not asking to match the JBehave Narrative: grammar, as Gherkin has diverged from it, and JBehave is a .story file, not a .feature file.

I'm also not asking specifically to syntax highlight the word to, though I'll leave this up to your discretion. The Cucumber page screenshots don't syntax hilight the word to, but as far as I've seen they're always present, and the original JBehave grammar mandated it.

Incorrect error display for Cucumber

I'm using :compiler cucumber + :make (or :Make with vim-dispatch) to run my cukes.
For some reason, a successful pass will always be shown as having an error:

Feature: Success

  Scenario: Success     # features/success.feature:2
    When I do something # features/steps.rb:1
    Then I succeed      # features/steps.rb:4

1 scenario (<<< THIS LINE MARKED AS ERROR)
2 steps
0m0.016s

See demo below:

cucumber-incorrect-errors

I'm using MacVim snapshot 73 (VIM 7.4.258) with bundled cucumber.vim compiler matching this one here.

Other compilers - e.g. rspec - work fine and only mark errors where there are any.

Any idea why this is happening?

Segmentation fault

I get a segfault whenever I try to use this plugin:
screen shot 2015-02-02 at 9 44 30 am

Here is my vim info:

~/Work/hubble vim --version
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Dec 15 2014 13:35:47)
MacOS X (unix) version
Included patches: 1-488
Compiled by Homebrew
Huge version without GUI.  Features included (+) or not (-):
+acl             +farsi           +mouse_netterm   +syntax
+arabic          +file_in_path    +mouse_sgr       +tag_binary
+autocmd         +find_in_path    -mouse_sysmouse  +tag_old_static
-balloon_eval    +float           +mouse_urxvt     -tag_any_white
-browse          +folding         +mouse_xterm     -tcl
++builtin_terms  -footer          +multi_byte      +terminfo
+byte_offset     +fork()          +multi_lang      +termresponse
+cindent         -gettext         -mzscheme        +textobjects
-clientserver    -hangul_input    +netbeans_intg   +title
+clipboard       +iconv           +path_extra      -toolbar
+cmdline_compl   +insert_expand   +perl            +user_commands
+cmdline_hist    +jumplist        +persistent_undo +vertsplit
+cmdline_info    +keymap          +postscript      +virtualedit
+comments        +langmap         +printer         +visual
+conceal         +libcall         +profile         +visualextra
+cryptv          +linebreak       +python          +viminfo
+cscope          +lispindent      -python3         +vreplace
+cursorbind      +listcmds        +quickfix        +wildignore
+cursorshape     +localmap        +reltime         +wildmenu
+dialog_con      -lua             +rightleft       +windows
+diff            +menu            +ruby            +writebackup
+digraphs        +mksession       +scrollbind      -X11
-dnd             +modify_fname    +signs           -xfontset
-ebcdic          +mouse           +smartindent     -xim
+emacs_tags      -mouseshape      -sniff           -xsmp
+eval            +mouse_dec       +startuptime     -xterm_clipboard
+ex_extra        -mouse_gpm       +statusline      -xterm_save
+extra_search    -mouse_jsbterm   -sun_workshop    -xpm
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
  fall-back for $VIM: "/usr/local/share/vim"
Compilation: /usr/bin/clang -c -I. -Iproto -DHAVE_CONFIG_H   -F/usr/local/Frameworks -DMACOS_X_UNIX  -Os -w -pipe -march=native -mmacosx-version-min=10.10 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: /usr/bin/clang   -L. -L/Users/travis/.sm/pkg/active/lib -fPIC -Bstatic -fstack-protector -L/usr/local/lib -F/usr/local/Frameworks -Wl,-headerpad_max_install_names -o vim        -lm  -lncurses -liconv -framework Cocoa   -fstack-protector  -L/System/Library/Perl/5.18/darwin-thread-multi-2level/CORE -lperl -framework Python   -lruby-static -framework CoreFoundation -lgmp -lobjc -L/Users/krisluminar/.rvm/rubies/ruby-2.1.4/lib

And my list of pathogen plugins:

~/Work/hubble ll ~/.vim/bundle
total 80
drwxr-xr-x   7 krisluminar  staff   238B Dec 15 14:53 DeleteTrailingWhitespace
drwxr-xr-x   9 krisluminar  staff   306B Dec 15 15:30 ack.vim
drwxr-xr-x   5 krisluminar  staff   170B Dec 17 15:22 file-line
drwxr-xr-x  11 krisluminar  staff   374B Dec 15 13:46 nerdtree
drwxr-xr-x   9 krisluminar  staff   306B Dec 17 14:56 tabular
-rw-r--r--   1 krisluminar  staff    36K Dec 17 13:50 tags
drwxr-xr-x   6 krisluminar  staff   204B Dec 16 08:45 tcomment
drwxr-xr-x   9 krisluminar  staff   306B Dec 17 13:47 vim-bundler
drwxr-xr-x  19 krisluminar  staff   646B Dec 15 14:21 vim-coffee-script
drwxr-xr-x   9 krisluminar  staff   306B Jan 28 10:57 vim-cucumber
drwxr-xr-x   8 krisluminar  staff   272B Dec 17 11:31 vim-fugitive
drwxr-xr-x  10 krisluminar  staff   340B Dec 15 15:00 vim-gitgutter
drwxr-xr-x   9 krisluminar  staff   306B Dec 17 09:36 vim-indent-guides
drwxr-xr-x   9 krisluminar  staff   306B Dec 17 13:45 vim-rails
drwxr-xr-x  21 krisluminar  staff   714B Dec 17 13:45 vim-ruby
drwxr-xr-x   5 krisluminar  staff   170B Dec 15 13:45 vim-sensible
drwxr-xr-x   6 krisluminar  staff   204B Jan 26 08:35 vim-windowswap

Does anyone have any ideas how to fix this?

Feature: Jump back to feature file?

First off -- thank you 100000x! Jumping into a step definition is huge. I'd love to be able to jump back without resorting to a split screen (like I can with the tag stack). I tried all the commands listed in the README and none were quite what I was looking for. Thanks!

Changing the default indentation

Apologies if this is the wrong place to ask a question.

I have been using the carlhuda/janus vim distribution for about 5 years. I use vim daily, but I have very little understand of how packages/plug-ins/customizations work.

Recently, janus switched to the vim-polyglot plug-in which includes this package. Maybe janus always used this package? I will admit that I don't really know.

What I do know is now vim is not indenting my cucumber features like it did before and this is really disruptive because I write a lot of cucumbers.

Is it possible to change the default indentation? What I really want is to have no indention at all.

I have tried to disable the language support using the instructions on the vim-polyglot site, but without success.

I am also trying to get help from the carlhuda/janus community.

jump to gerkin files with tabs

I came across a file in our source tree were the jump to step definition wasn't working. Investigation indicated that this was due to use indent returning the wrong string start position when tabs are used. The following works for me but I'm not sure whether there is better vim api to use.

diff --git a/ftplugin/cucumber.vim b/ftplugin/cucumber.vim
index fb31fde..46e7024 100644
--- a/ftplugin/cucumber.vim
+++ b/ftplugin/cucumber.vim
@@ -71,7 +71,8 @@ function! s:allsteps()
 endfunction

 function! s:steps(lnum)
-  let c = indent(a:lnum) + 1
+  "let c = indent(a:lnum) + 1
+  let c = match(getline(a:lnum), '\S') + 1
   while synIDattr(synID(a:lnum,c,1),'name') !~# '^$\|Region$'
     let c = c + 1
   endwhile

Cucumber 1.2.2 step snippets now have parentheses, breaking ctrl-]

This commit broke the "jump to step" functionality in vim-cucumber. The commit is part of cucumber 1.2.2 that was released on March 2nd.

Step snippets now look like this:

# You can implement step definitions for undefined steps with these snippets:

Given(/^I do not have this step yet$/) do
  pending # express the regexp above with the code you wish you had
end

(note the added parentheses around the regular expression).

When these snippets are copy-pasted into step definition files, pressing ctrl-] in the Cucumber feature will result in "No matching step found".

Gherkin 8

With the release of Gherkin 8 and Cucumbers using it, syntax highlighting will need to be updated to support the new keywords.

<C-]> clashing with jump to tag from tags

I have the ctags plugin installed as well and when I press CTRL-] or any combination of the presses that should open up the step definitions, I end up on the method definition of things like "Given" etc.

I tried remapping <C-]> to in ftplugin/cucumber.vim but to no avail ?

Any ideas ? :(

Some way to go back after jumping to step definition

It would be awesome if vim's tag stack could be used when jumping to step definitions, meaning that <C-t> would jump back again to the feature again.

Perhaps there is some way to get this working without having to add extra functionality to vim-cucumber?

Strictly ruby specific? No matching steps

I've been trying to get this to work in a larger python/JS/TS project and have had 0 luck configuring it to find matching steps. I scanned the repo and only saw one spot where it was searching for .rb files. I've even tried some of the forks/PR's people have created for configuring paths via env vars and preferring vimscript and falling back to ruby.

Could it be the way some of the regex's are defined that are ruby specific?

All our step files follow the usual paths:
/cypress/integration/**/*.cucumber.ts

I've combined a few of the relevant commits in my fork here:
https://github.com/Gee19/vim-cucumber

pytest-bdd syntax support

pytest-bdd uses a slightly different syntax for multiline steps than the original doc strings/pystrings defined in gherkin.

Will it be possible to adjust the syntax to support this use-case as well?

Instead of:

Feature: Multiline steps
    Scenario: Multiline step using sub indentation
        Given I have a step with:
            """
            Some
            Extra
            Lines
            """
        Then the text should be parsed with correct indentation

They use

Feature: Multiline steps
    Scenario: Multiline step using sub indentation
        Given I have a step with:
            Some
            Extra
            Lines
        Then the text should be parsed with correct indentation

vim.org

Any chance of adding this to vim.org?

Cucumber table alignment

It would be extremely nice if we can have ability to hit indent and the table data be aligned as well. The textmate bundle has this feature which is, in my opinion, very powerful.

Optional quotes prevent vim-cucumber from finding a step

I have the following steps in my feature file:

    And I swipe "left" a random number of times
    And I swipe "right" a random number of times

and the following step definition:

    Given(/^I swipe "?([^"]*)"? a random number of times$/) do |direction|

With this step definition, ]{Ctrl-D} yields "E388: Couldn't find definition"
However, if I remove the two question marks and just use this:

    Given(/^I swipe "([^"]*)" a random number of times$/) do |direction|

Then vim-cucumber finds the step as expected.
Regardless of which version of the step definition I use, cucumber properly accesses the step.

Missing any documentation on how to configure steps and omnifunc

First of all thanks for the great plugin, I totally underrated it because it was not doing any auto-completion, just until I found out it does!
Is there any reason why in the readme you don't mention to set b:cucumber_steps_glob and that you can use the omnifunc out of the box?
It's fairly trivial to find it in the source code but I think it should be written somewhere.
Let me know if I missed it and it is there already. Otherwise I could even open a PR myself

Display list of matching steps

It would be great if matching step definitions were displayed and the option for jumping to the appropriate step definition were provided.

Fix syntax highlighting for matchers using parentheses

Hi,

As discussed in this PR, the correct syntax for Gherkin matchers is

Given(/This and that/)

And not

Given /This and that/

because the latter is ambiguous and causes ruby to issue the warning ambiguous first argument; put parentheses or even spaces. (note: funny that the GitHub syntax highlight makes the same mistake)

It would be great if the syntax file in this plugin could highlight the correct case (and possibly, stop highlighting the wrong one!)

Thanks for all your great plugins ❤️

Step reported as Cucumber::Undefined but can be jumped to

I'm seeing vim report Cucumber::Undefined for steps that work fine with cucumber, and that cucumber-vim will let me jump to with ctrl-w d. So it seems like cucumber-vim knows how to find the steps.

Is it a directory structure thing? This project uses steps instead of step_definitions, though I tried switching the name of the directory and it didn't matter. I also tried un-nesting the .feature file I'm working on and putting it at the top level features directory like (features/my_file.feature) to see if it could find the step defs that way but that didn't matter either.

I'm stumped. Any ideas? Thanks much!

image

Horizontal vs Vertical Split

When i open up a step definition for a feature step, the definition always opens in a horizontal split (not wanted) vs a vertical split (wanted)

Do you know what could be causing that?

Thanks!

Installing using pathogen.vim

Gday Tim,

Any chance you can make this installable with pathogen.vim? I'm using a bunch of your other plugins that use it, and it seems to me a much cleaner way of installing.

Thanks for all the hard work mate.

Not finding available step

I have a step definition:

When(/^I navigate to any "(\d+)" PDP page(?:s?)$/) do |pdp_page_count|

and I access it with:

    When I navigate to any "2" PDP pages

However, when I try to jump to the definition, all I get is:

E388: Couldn't find definition

It all works when I run Cucumber...

Syntax highlight for preferred syntax with parens

Cucumber is now generated step definitions including parenthesis, I don't particularly like the idea but the thing is that omitting parentheses does generate a warning when running ruby -w on it, also on syntastic as well. As I said now the generated step definitions that you get when you have an undefined step do include the parens so I'm guessing this is now the preferred way to go. I updated my project through some argdo stuff but I don't know if it had something to do with it, but I'm pretty sure that's not the case. The issue comes that vim-cucumber isn't syntax highlighting any Given/When/Then/And/But keywords if they're immediately surrounded by parens like in Given(/Something that I use to know/) doesn't get highlighted. Would you please fix this, or point me in the way of doing it. My knowledge of vimscript is fairly limited even when it comes to syntax files.

Asterisk keywords are not recognized

I have several cucumber files with constructs like this:

    Then SGC 1 received SSA with:
    * Destination-PC 1-1-1
    * Affected-PC 2-2-2
    * Affected-SSN 1
    And SGC 1 marked as ALLOWED status of all remote SSNs for PC 2-2-2
    And SGC 1 has stopped all subsystem status test procedures for PC 2-2-2
    And SGC 1 updated outbound translation tables

The asterisks seem to throw the plugin off, you can't jump to the corresponding steps and the Ands at the end are also not recognized and consequently cannot be jumped to.

Multi-line string breaks highlighting

It appears that when I add a multiline string in between an explicit Given statement and subsequent And statements, syntax highlighting breaks for all subsequent And statements. Highlighting returns to normal when I give another explicit Given, When, or Then statement.

Possibility to find step usages

I'm pretty sure there is no such thing in the plugin, but I guess it'd extremely useful.
ATM I'm using macros like thislet @s='?/\^?s+2y/\("\|\$\):lvimgrep /<C-R>"/j features/**/*.feature<CR>:lopen<CR>'
Hopefully someone could suggest a better way to do that.

Using apostrophe in step name breaks syntax highlighting

Everything after the apostrophe in "I'm" is treated as text by the syntax highlighter.

Given /^I'm logged in$/ do
  pending # express the regexp above with the code you wish you had
end

Since the method name is a regex apostrophe's shouldn't be unexpected. I have no idea how hard it would be to fix this though.

syntax highlighting broken with multiple scenario keywords

I'm using vim 7.3 and installed the latest vim-cucumber as a pathogen bundle from master. I started editing a feature file which had multiple scenarios and noticed that the syntax highlighting for the second and subsequent "Scenario" keywords only had the "S" from "Scenario" highlighted. The first "Scenario" keyword was correctly highlighted.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.