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/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. 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],' %#')