From 8e4fb8e96d238fd55b92fec4bc8c25b62f689b18 Mon Sep 17 00:00:00 2001 From: yc98js1 Date: Mon, 5 Jan 2015 18:20:40 -0800 Subject: [PATCH 1/6] Add basic documentation file --- doc/vim-cucumber.txt | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 doc/vim-cucumber.txt diff --git a/doc/vim-cucumber.txt b/doc/vim-cucumber.txt new file mode 100644 index 0000000..f8d881e --- /dev/null +++ b/doc/vim-cucumber.txt @@ -0,0 +1,32 @@ +*vim-cucumber.txt* Simple docs for those of us suffering from CRS + +Author: Jonathan Seidel +License: Same terms as vim itself ( see |license|) + +INTRODUCTION *vim-cucumber* + +When working with cucumber, several useful commands are defined +that let you work with feature files and step definitions seamlessly. + +MAPPINGS *vim-cucumber-mappings* + +These mappings are available in your local buffers. + + *vim-cucumber_[* + *vim-cucumber_]* +[ on a step jumps to the corresponding step definition and +] replaces the current buffer. + + *vim-cucumber_d* + *vim-cucumber_* +d on a step jumps to its definition in a new split buffer + and moves the cursor there. + + *vim-cucumber_[d* + *vim-cucumber_]d* +[d on a step jumps to its definition in a new split buffer +]d while maintaining the current cursor position. + + *vim-cucumber_* + Return from the step definition to the feature file + after having used the [ mapping. From 686870b116c2f89e1bcadec966eb0d97454abd2a Mon Sep 17 00:00:00 2001 From: Jonathan Seidel Date: Fri, 6 Mar 2015 07:57:11 -0800 Subject: [PATCH 2/6] Begin mods to specify cucumber root --- ftplugin/cucumber.vim | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ftplugin/cucumber.vim b/ftplugin/cucumber.vim index b2f60fd..25325ec 100644 --- a/ftplugin/cucumber.vim +++ b/ftplugin/cucumber.vim @@ -18,7 +18,9 @@ setlocal omnifunc=CucumberComplete let b:undo_ftplugin = "setl fo< com< cms< ofu<" -let b:cucumber_root = expand('%:p:h:s?.*[\/]\%(features\|stories\)\zs[\/].*??') +" let b:cucumber_root = expand('%:p:h:s?.*[\/]\%(features\|stories\)\zs[\/].*??') +let b:cucumber_root = expand('%:p:h:s?.*[\/]\%(features\|stories\)/step_definitions/mobile_website/\zs[\/].*??') +echo b:cucumber_root if !exists("g:no_plugin_maps") && !exists("g:no_cucumber_maps") cnoremap foldopen if &foldopen =~# 'tag'exe 'norm! zv'endif From c066479afaf26d30e338c7f2b52ca8978f7dfcbf Mon Sep 17 00:00:00 2001 From: Jonathan Seidel Date: Fri, 6 Mar 2015 08:03:56 -0800 Subject: [PATCH 3/6] Undo cucumber_root: doesn't work... Believe he expectes a directory step_definitions/ under the root; regroup --- ftplugin/cucumber.vim | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/ftplugin/cucumber.vim b/ftplugin/cucumber.vim index 25325ec..b2f60fd 100644 --- a/ftplugin/cucumber.vim +++ b/ftplugin/cucumber.vim @@ -18,9 +18,7 @@ setlocal omnifunc=CucumberComplete let b:undo_ftplugin = "setl fo< com< cms< ofu<" -" let b:cucumber_root = expand('%:p:h:s?.*[\/]\%(features\|stories\)\zs[\/].*??') -let b:cucumber_root = expand('%:p:h:s?.*[\/]\%(features\|stories\)/step_definitions/mobile_website/\zs[\/].*??') -echo b:cucumber_root +let b:cucumber_root = expand('%:p:h:s?.*[\/]\%(features\|stories\)\zs[\/].*??') if !exists("g:no_plugin_maps") && !exists("g:no_cucumber_maps") cnoremap foldopen if &foldopen =~# 'tag'exe 'norm! zv'endif From 7718bbf2cbb15449acbc0d643e3fc4bc46f1ad97 Mon Sep 17 00:00:00 2001 From: Jonathan Seidel Date: Thu, 12 Mar 2015 09:52:49 -0700 Subject: [PATCH 4/6] Update for new cucumber root --- ftplugin/cucumber.vim | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ftplugin/cucumber.vim b/ftplugin/cucumber.vim index b2f60fd..6f3ae16 100644 --- a/ftplugin/cucumber.vim +++ b/ftplugin/cucumber.vim @@ -18,7 +18,9 @@ setlocal omnifunc=CucumberComplete let b:undo_ftplugin = "setl fo< com< cms< ofu<" -let b:cucumber_root = expand('%:p:h:s?.*[\/]\%(features\|stories\)\zs[\/].*??') +" let b:cucumber_root = expand('%:p:h:s?.*[\/]\%(features\|stories\)\zs[\/].*??') +let b:cucumber_root = expand('%:p:h:s?.*[\/]\%(features\|stories\)/step_definitions/mobile_website\zs[\/].*??') +echo 'cucumber_root = ' + b:cucumber_root if !exists("g:no_plugin_maps") && !exists("g:no_cucumber_maps") cnoremap foldopen if &foldopen =~# 'tag'exe 'norm! zv'endif @@ -37,6 +39,9 @@ if !exists("g:no_plugin_maps") && !exists("g:no_cucumber_maps") \ "|sil! nunmap ]d" endif +function! VimCucumberRoot() + echo 'cucumber_root = ' + b:cucumber_root +endfunction function! s:jump(command,count) let steps = s:steps('.') if len(steps) == 0 || len(steps) < a:count From 6ee1fede7db7e6bb2d8af9c560dd033029297641 Mon Sep 17 00:00:00 2001 From: Jonathan Seidel Date: Mon, 30 Mar 2015 08:41:14 -0700 Subject: [PATCH 5/6] Updated b:cucumber_root --- ftplugin/cucumber.vim | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/ftplugin/cucumber.vim b/ftplugin/cucumber.vim index 6f3ae16..fbd3311 100644 --- a/ftplugin/cucumber.vim +++ b/ftplugin/cucumber.vim @@ -20,7 +20,12 @@ let b:undo_ftplugin = "setl fo< com< cms< ofu<" " let b:cucumber_root = expand('%:p:h:s?.*[\/]\%(features\|stories\)\zs[\/].*??') let b:cucumber_root = expand('%:p:h:s?.*[\/]\%(features\|stories\)/step_definitions/mobile_website\zs[\/].*??') -echo 'cucumber_root = ' + b:cucumber_root +" let b:cucumber_root = expand('/Users/yc98js1/dev/QAA/features/step_definitions/mobile_website/.*??') +echom 'cucumber_root = ' . b:cucumber_root +function! VimCucumberRoot(root) + return root +endfunction +command! VimCucumberRoot :call VimCucumberRoot(b:cucumber_root)) if !exists("g:no_plugin_maps") && !exists("g:no_cucumber_maps") cnoremap foldopen if &foldopen =~# 'tag'exe 'norm! zv'endif @@ -39,9 +44,6 @@ if !exists("g:no_plugin_maps") && !exists("g:no_cucumber_maps") \ "|sil! nunmap ]d" endif -function! VimCucumberRoot() - echo 'cucumber_root = ' + b:cucumber_root -endfunction function! s:jump(command,count) let steps = s:steps('.') if len(steps) == 0 || len(steps) < a:count From 50ba53eb6285b7fea70df2d19b5c1378cf29a758 Mon Sep 17 00:00:00 2001 From: Jon Seidel Date: Sat, 28 May 2016 09:58:16 -0700 Subject: [PATCH 6/6] Support CUKEFILES ENV variable... CUKEFILES environment variable can set the matching cucumber 'root' files. Add number of matching files to "Multiple steps..." message Add CUKEFILES documentation to README.markdown --- README.markdown | 18 ++++++++++++++++++ ftplugin/cucumber.vim | 16 +++++++++++++--- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/README.markdown b/README.markdown index 4295436..f9d604a 100644 --- a/README.markdown +++ b/README.markdown @@ -15,6 +15,24 @@ corresponding step definition and replaces the current buffer. `d` or the cursor there. `[d` or `]d` on a step opens the step definition in a new split buffer while maintaining the current cursor position. +## Runtime Options + +vim-cucumber looks through steps defined in your 'features' or 'stories' folder. +Usually this is OK, but if you work in a multi-project environment, where each +project has its own sub-folder, this can lead to many occurences of 'Multiple +matching steps...' and extra work to find the step that your project uses. + +To avoid this situation, you can export the CUKEFILES environment variable as a +glob specification, which will then be used in place of the default. An example +would be: + + export CUKEFILES='/Users/jesii/features/step\_definitions/mobweb/\*\*/\*.rb' + +## Documentation + +Standard vim documentation is available through: + :h vim-cucumber + ## Installation If you don't have a preferred installation method, I recommend installing diff --git a/ftplugin/cucumber.vim b/ftplugin/cucumber.vim index af734ee..f58cfed 100644 --- a/ftplugin/cucumber.vim +++ b/ftplugin/cucumber.vim @@ -1,7 +1,7 @@ " Vim filetype plugin " Language: Cucumber " Maintainer: Tim Pope -" Last Change: 2013 Jun 01 +" Last Change: 2016 May 28 " Only do this when not done yet for this buffer if (exists("b:did_ftplugin")) @@ -18,9 +18,19 @@ setlocal omnifunc=CucumberComplete let b:undo_ftplugin = "setl fo< com< cms< ofu<" +" Allow setting the cucumber-root to a different value, +" via ENV variable CUKEFILES +" This is the default let b:cucumber_root = expand('%:p:h:s?.*[\/]\%(features\|stories\)\zs[\/].*??') + if !exists("b:cucumber_steps_glob") - let b:cucumber_steps_glob = b:cucumber_root.'/**/*.rb' + if empty($CUKEFILES) + echom "Using default definition for b:cucumber_steps_glob" + let b:cucumber_steps_glob = b:cucumber_root.'/**/*.rb' + else + echom 'Using CUKEFILES environment variable for b:cucumber_steps_glob' + let b:cucumber_steps_glob = $CUKEFILES + endif endif if !exists("g:no_plugin_maps") && !exists("g:no_cucumber_maps") @@ -45,7 +55,7 @@ function! s:jump(command,count) if len(steps) == 0 || len(steps) < a:count return 'echoerr "No matching step found"' elseif len(steps) > 1 && !a:count - return 'echoerr "Multiple matching steps found"' + return 'echoerr "Multiple matching steps (" . len(steps) . ") found"' else let c = a:count ? a:count-1 : 0 return a:command.' +'.steps[c][1].' '.escape(steps[c][0],' %#')