Mercurial > vim
comparison runtime/ftplugin/cucumber.vim @ 4681:2eb30f341e8d
Updated runtime files and translations.
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Sat, 01 Jun 2013 14:50:56 +0200 |
parents | 713a4965ee7f |
children | 43efa4f5a8ea |
comparison
equal
deleted
inserted
replaced
4680:fd8cc7fbc273 | 4681:2eb30f341e8d |
---|---|
1 " Vim filetype plugin | 1 " Vim filetype plugin |
2 " Language: Cucumber | 2 " Language: Cucumber |
3 " Maintainer: Tim Pope <vimNOSPAM@tpope.org> | 3 " Maintainer: Tim Pope <vimNOSPAM@tpope.org> |
4 " Last Change: 2010 Aug 09 | 4 " Last Change: 2013 Jun 01 |
5 | 5 |
6 " Only do this when not done yet for this buffer | 6 " Only do this when not done yet for this buffer |
7 if (exists("b:did_ftplugin")) | 7 if (exists("b:did_ftplugin")) |
8 finish | 8 finish |
9 endif | 9 endif |
10 let b:did_ftplugin = 1 | 10 let b:did_ftplugin = 1 |
11 | |
12 let s:keepcpo= &cpo | |
13 set cpo&vim | |
11 | 14 |
12 setlocal formatoptions-=t formatoptions+=croql | 15 setlocal formatoptions-=t formatoptions+=croql |
13 setlocal comments=:# commentstring=#\ %s | 16 setlocal comments=:# commentstring=#\ %s |
14 setlocal omnifunc=CucumberComplete | 17 setlocal omnifunc=CucumberComplete |
15 | 18 |
16 let b:undo_ftplugin = "setl fo< com< cms< ofu<" | 19 let b:undo_ftplugin = "setl fo< com< cms< ofu<" |
17 | 20 |
18 let b:cucumber_root = expand('%:p:h:s?.*[\/]\%(features\|stories\)\zs[\/].*??') | 21 let b:cucumber_root = expand('%:p:h:s?.*[\/]\%(features\|stories\)\zs[\/].*??') |
19 | 22 |
20 if !exists("g:no_plugin_maps") && !exists("g:no_cucumber_maps") | 23 if !exists("g:no_plugin_maps") && !exists("g:no_cucumber_maps") |
21 nmap <silent><buffer> <C-]> :<C-U>exe <SID>jump('edit',v:count)<CR> | 24 nnoremap <silent><buffer> <C-]> :<C-U>exe <SID>jump('edit',v:count)<CR> |
22 nmap <silent><buffer> <C-W>] :<C-U>exe <SID>jump('split',v:count)<CR> | 25 nnoremap <silent><buffer> [<C-D> :<C-U>exe <SID>jump('edit',v:count)<CR> |
23 nmap <silent><buffer> <C-W><C-]> :<C-U>exe <SID>jump('split',v:count)<CR> | 26 nnoremap <silent><buffer> ]<C-D> :<C-U>exe <SID>jump('edit',v:count)<CR> |
24 nmap <silent><buffer> <C-W>} :<C-U>exe <SID>jump('pedit',v:count)<CR> | 27 nnoremap <silent><buffer> <C-W>] :<C-U>exe <SID>jump('split',v:count)<CR> |
25 let b:undo_ftplugin .= "| sil! iunmap! <C-]>| sil! iunmap! <C-W>]| sil! iunmap! <C-W><C-]>| sil! iunmap! <C-W>}" | 28 nnoremap <silent><buffer> <C-W><C-]> :<C-U>exe <SID>jump('split',v:count)<CR> |
29 nnoremap <silent><buffer> <C-W>d :<C-U>exe <SID>jump('split',v:count)<CR> | |
30 nnoremap <silent><buffer> <C-W><C-D> :<C-U>exe <SID>jump('split',v:count)<CR> | |
31 nnoremap <silent><buffer> <C-W>} :<C-U>exe <SID>jump('pedit',v:count)<CR> | |
32 nnoremap <silent><buffer> [d :<C-U>exe <SID>jump('pedit',v:count)<CR> | |
33 nnoremap <silent><buffer> ]d :<C-U>exe <SID>jump('pedit',v:count)<CR> | |
34 let b:undo_ftplugin .= | |
35 \ "|sil! nunmap <buffer> <C-]>" . | |
36 \ "|sil! nunmap <buffer> [<C-D>" . | |
37 \ "|sil! nunmap <buffer> ]<C-D>" . | |
38 \ "|sil! nunmap <buffer> <C-W>]" . | |
39 \ "|sil! nunmap <buffer> <C-W><C-]>" . | |
40 \ "|sil! nunmap <buffer> <C-W>d" . | |
41 \ "|sil! nunmap <buffer> <C-W><C-D>" . | |
42 \ "|sil! nunmap <buffer> <C-W>}" . | |
43 \ "|sil! nunmap <buffer> [d" . | |
44 \ "|sil! nunmap <buffer> ]d" | |
26 endif | 45 endif |
27 | 46 |
28 function! s:jump(command,count) | 47 function! s:jump(command,count) |
29 let steps = s:steps('.') | 48 let steps = s:steps('.') |
30 if len(steps) == 0 || len(steps) < a:count | 49 if len(steps) == 0 || len(steps) < a:count |
36 return a:command.' +'.steps[c][1].' '.escape(steps[c][0],' %#') | 55 return a:command.' +'.steps[c][1].' '.escape(steps[c][0],' %#') |
37 endif | 56 endif |
38 endfunction | 57 endfunction |
39 | 58 |
40 function! s:allsteps() | 59 function! s:allsteps() |
41 let step_pattern = '\C^\s*\K\k*\>\s*\zs\S.\{-\}\ze\s*\%(do\|{\)\s*\%(|[^|]*|\s*\)\=\%($\|#\)' | 60 let step_pattern = '\C^\s*\K\k*\>\s*(\=\s*\zs\S.\{-\}\ze\s*)\=\s*\%(do\|{\)\s*\%(|[^|]*|\s*\)\=\%($\|#\)' |
42 let steps = [] | 61 let steps = [] |
43 for file in split(glob(b:cucumber_root.'/**/*.rb'),"\n") | 62 for file in split(glob(b:cucumber_root.'/**/*.rb'),"\n") |
44 let lines = readfile(file) | 63 let lines = readfile(file) |
45 let num = 0 | 64 let num = 0 |
46 for line in lines | 65 for line in lines |
53 endfor | 72 endfor |
54 return steps | 73 return steps |
55 endfunction | 74 endfunction |
56 | 75 |
57 function! s:steps(lnum) | 76 function! s:steps(lnum) |
58 let c = indent(a:lnum) + 1 | 77 let c = match(getline(a:lnum), '\S') + 1 |
59 while synIDattr(synID(a:lnum,c,1),'name') !~# '^$\|Region$' | 78 while synIDattr(synID(a:lnum,c,1),'name') !~# '^$\|Region$' |
60 let c = c + 1 | 79 let c = c + 1 |
61 endwhile | 80 endwhile |
62 let step = matchstr(getline(a:lnum)[c-1 : -1],'^\s*\zs.\{-\}\ze\s*$') | 81 let step = matchstr(getline(a:lnum)[c-1 : -1],'^\s*\zs.\{-\}\ze\s*$') |
63 return filter(s:allsteps(),'s:stepmatch(v:val[3],step)') | 82 return filter(s:allsteps(),'s:stepmatch(v:val[3],step)') |
127 endfor | 146 endfor |
128 call filter(steps,'strpart(v:val,0,strlen(a:base)) ==# a:base') | 147 call filter(steps,'strpart(v:val,0,strlen(a:base)) ==# a:base') |
129 return sort(steps) | 148 return sort(steps) |
130 endfunction | 149 endfunction |
131 | 150 |
151 let &cpo = s:keepcpo | |
152 unlet s:keepcpo | |
153 | |
132 " vim:set sts=2 sw=2: | 154 " vim:set sts=2 sw=2: |