Permalink
Browse files

Adding vim stuff.

  • Loading branch information...
1 parent 71df2dd commit a3351c894e6c59a7559ebb4af85bcedce10bacb0 @benhutton committed Jul 6, 2010
View

Large diffs are not rendered by default.

Oops, something went wrong.
View

Large diffs are not rendered by default.

Oops, something went wrong.
View

Large diffs are not rendered by default.

Oops, something went wrong.
View

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -0,0 +1,77 @@
+" vim: set ts=2 sw=2 sts=2:
+set background=dark
+hi clear
+if exists("syntax_on")
+ syntax reset
+endif
+
+let colors_name = "mint"
+set mouseshape+=i:arrow
+
+" Window elements
+hi Cursor guifg=#000000 guibg=#F0F0F0
+hi Folded guifg=#FFD19D guibg=#AA8C00 gui=none
+hi LineNr guifg=#CCCCCC guibg=#666633
+hi NonText guifg=#CCCCCC
+hi MatchParen guibg=#555555 gui=underline
+hi Normal guifg=#F5F5F5 guibg=#333333
+hi CursorLine guibg=#666666
+hi StatusLine guifg=#997777 guibg=#FFFFFF
+hi StatusLineNC guifg=#777777 guibg=#CCCCCC
+hi Visual guifg=#EEEEEE guibg=#777799
+hi Search guibg=#AAAACC
+hi Pmenu guifg=#F5F5F5 guibg=steelblue
+hi PmenuSel guifg=orange guibg=steelblue
+
+" Main groups
+hi Comment guifg=#C0C0C0 gui=italic
+hi Constant guifg=#EEDDAA gui=none
+
+hi Statement guifg=#CCEE00
+hi Keyword guifg=#CCEE00
+hi Underlined guifg=#E0E0E0 gui=underline
+hi Error guifg=#F5F5F5 guibg=darkgoldenrod
+
+" Tag syntax
+hi Attribute guifg=#CCCCCC gui=italic
+
+hi String guifg=#FFCC99
+hi! link Character Constant
+hi! link Number Constant
+hi! link Boolean Constant
+hi! link Float Constant
+
+hi Identifier guifg=#CCDDFF
+hi Function guifg=#CCEE00
+
+hi Operator guifg=#F5F5F5
+hi! link Preproc Keyword
+hi! link Type Keyword
+
+hi! link Special Keyword
+hi! link Ignore Normal
+hi! link Todo Error
+
+hi! link Title Normal
+
+" minibufexplorer
+hi MBENormal guifg=gray90
+hi! link MBEChanged Keyword
+hi MBEVisibleNormal guibg=#AFC900 guifg=black gui=italic
+hi! link MBEVisibleChanged MBEVisibleNormal
+
+
+" HTML
+hi HTMLString guifg=#F0D0C0 gui=italic
+
+" PLSQL
+" count, max, min, etc
+hi plsqlFunction guifg=#FFAAAA
+" currval, nextval, etc
+hi! link plsqlPseudo Keyword
+hi plsqlConditional guifg=#99CCFF
+hi plsqlRepeat guifg=#99CCFF
+" integer, number
+hi plsqlStorage guifg=wheat
+hi! link plsqlTypeAttribute plsqlStorage
+hi! link plsqlAttribute plsqlStorage
@@ -0,0 +1,2 @@
+" Cucumber
+autocmd BufNewFile,BufReadPost *.feature,*.story set filetype=cucumber
View
@@ -0,0 +1,131 @@
+" Vim filetype plugin
+" Language: Cucumber
+" Maintainer: Tim Pope <vimNOSPAM@tpope.org>
+
+" Only do this when not done yet for this buffer
+if (exists("b:did_ftplugin"))
+ finish
+endif
+let b:did_ftplugin = 1
+
+setlocal formatoptions-=t formatoptions+=croql
+setlocal comments=:# commentstring=#\ %s
+setlocal omnifunc=CucumberComplete
+
+let b:undo_ftplugin = "setl fo< com< cms< ofu<"
+
+let b:cucumber_root = expand('%:p:h:s?.*[\/]\%(features\|stories\)\zs[\/].*??')
+
+if !exists("g:no_plugin_maps") && !exists("g:no_cucumber_maps")
+ nmap <silent><buffer> <C-]> :<C-U>exe <SID>jump('edit',v:count)<CR>
+ nmap <silent><buffer> <C-W>] :<C-U>exe <SID>jump('split',v:count)<CR>
+ nmap <silent><buffer> <C-W><C-]> :<C-U>exe <SID>jump('split',v:count)<CR>
+ nmap <silent><buffer> <C-W>} :<C-U>exe <SID>jump('pedit',v:count)<CR>
+ let b:undo_ftplugin .= "| sil! iunmap! <C-]>| sil! iunmap! <C-W>]| sil! iunmap! <C-W><C-]>| sil! iunmap! <C-W>}"
+endif
+
+function! s:jump(command,count)
+ let steps = s:steps('.')
+ 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"'
+ else
+ let c = a:count ? a:count-1 : 0
+ return a:command.' +'.steps[c][1].' '.escape(steps[c][0],' %#')
+ endif
+endfunction
+
+function! s:allsteps()
+ let step_pattern = '\C^\s*\K\k*\>\s*\zs\S.\{-\}\ze\s*\%(do\|{\)\s*\%(|[^|]*|\s*\)\=\%($\|#\)'
+ let steps = []
+ for file in split(glob(b:cucumber_root.'/**/*.rb'),"\n")
+ let lines = readfile(file)
+ let num = 0
+ for line in lines
+ let num += 1
+ if line =~ step_pattern
+ let type = matchstr(line,'\w\+')
+ let steps += [[file,num,type,matchstr(line,step_pattern)]]
+ endif
+ endfor
+ endfor
+ return steps
+endfunction
+
+function! s:steps(lnum)
+ let c = indent(a:lnum) + 1
+ while synIDattr(synID(a:lnum,c,1),'name') !~# '^$\|Region$'
+ let c = c + 1
+ endwhile
+ let step = matchstr(getline(a:lnum)[c-1 : -1],'^\s*\zs.\{-\}\ze\s*$')
+ return filter(s:allsteps(),'s:stepmatch(v:val[3],step)')
+endfunction
+
+function! s:stepmatch(receiver,target)
+ if a:receiver =~ '^[''"].*[''"]$'
+ let pattern = '^'.escape(substitute(a:receiver[1:-2],'$\w\+','(.*)','g'),'/').'$'
+ elseif a:receiver =~ '^/.*/$'
+ let pattern = a:receiver[1:-2]
+ elseif a:receiver =~ '^%r..*.$'
+ let pattern = escape(a:receiver[3:-2],'/')
+ else
+ return 0
+ endif
+ try
+ let vimpattern = substitute(substitute(pattern,'\\\@<!(?:','%(','g'),'\\\@<!\*?','{-}','g')
+ if a:target =~# '\v'.vimpattern
+ return 1
+ endif
+ catch
+ endtry
+ if has("ruby")
+ ruby VIM.command("return #{if (begin; Kernel.eval('/'+VIM.evaluate('pattern')+'/'); rescue SyntaxError; end) === VIM.evaluate('a:target') then 1 else 0 end}")
+ else
+ return 0
+ endif
+endfunction
+
+function! s:bsub(target,pattern,replacement)
+ return substitute(a:target,'\C\\\@<!'.a:pattern,a:replacement,'g')
+endfunction
+
+function! CucumberComplete(findstart,base) abort
+ let indent = indent('.')
+ let group = synIDattr(synID(line('.'),indent+1,1),'name')
+ let type = matchstr(group,'\Ccucumber\zs\%(Given\|When\|Then\)')
+ let e = matchend(getline('.'),'^\s*\S\+\s')
+ if type == '' || col('.') < col('$') || e < 0
+ return -1
+ endif
+ if a:findstart
+ return e
+ endif
+ let steps = []
+ for step in s:allsteps()
+ if step[2] ==# type
+ if step[3] =~ '^[''"]'
+ let steps += [step[3][1:-2]]
+ elseif step[3] =~ '^/\^.*\$/$'
+ let pattern = step[3][2:-3]
+ let pattern = substitute(pattern,'\C^(?:|I )','I ','')
+ let pattern = s:bsub(pattern,'\\[Sw]','w')
+ let pattern = s:bsub(pattern,'\\d','1')
+ let pattern = s:bsub(pattern,'\\[sWD]',' ')
+ let pattern = s:bsub(pattern,'\[\^\\\="\]','_')
+ let pattern = s:bsub(pattern,'[[:alnum:]. _-][?*]?\=','')
+ let pattern = s:bsub(pattern,'\[\([^^]\).\{-\}\]','\1')
+ let pattern = s:bsub(pattern,'+?\=','')
+ let pattern = s:bsub(pattern,'(\([[:alnum:]. -]\{-\}\))','\1')
+ let pattern = s:bsub(pattern,'\\\([[:punct:]]\)','\1')
+ if pattern !~ '[\\()*?]'
+ let steps += [pattern]
+ endif
+ endif
+ endif
+ endfor
+ call filter(steps,'strpart(v:val,0,strlen(a:base)) ==# a:base')
+ return sort(steps)
+endfunction
+
+" vim:set sts=2 sw=2:
View
@@ -0,0 +1,59 @@
+" Vim indent file
+" Language: Cucumber
+" Maintainer: Tim Pope <vimNOSPAM@tpope.org>
+
+if exists("b:did_indent")
+ finish
+endif
+let b:did_indent = 1
+
+setlocal autoindent
+setlocal indentexpr=GetCucumberIndent()
+setlocal indentkeys=o,O,*<Return>,<:>,0<Bar>,0#,=,!^F
+
+" Only define the function once.
+if exists("*GetCucumberIndent")
+ finish
+endif
+
+function! s:syn(lnum)
+ return synIDattr(synID(a:lnum,1+indent(a:lnum),1),'name')
+endfunction
+
+function! GetCucumberIndent()
+ let line = getline(prevnonblank(v:lnum-1))
+ let cline = getline(v:lnum)
+ let syn = s:syn(prevnonblank(v:lnum-1))
+ let csyn = s:syn(v:lnum)
+ if csyn ==# 'cucumberFeature' || cline =~# '^\s*Feature:'
+ return 0
+ elseif csyn ==# 'cucumberExamples' || cline =~# '^\s*\%(Examples\|Scenarios\):'
+ return 2 * &sw
+ elseif csyn =~# '^cucumber\%(Background\|Scenario\|ScenarioOutline\)$' || cline =~# '^\s*\%(Background\|Scenario\|Scenario Outline\):'
+ return &sw
+ elseif syn ==# 'cucumberFeature' || line =~# '^\s*Feature:'
+ return &sw
+ elseif syn ==# 'cucumberExamples' || line =~# '^\s*\%(Examples\|Scenarios\):'
+ return 3 * &sw
+ elseif syn =~# '^cucumber\%(Background\|Scenario\|ScenarioOutline\)$' || line =~# '^\s*\%(Background\|Scenario\|Scenario Outline\):'
+ return 2 * &sw
+ elseif cline =~# '^\s*@' && (s:syn(nextnonblank(v:lnum+1)) == 'cucumberFeature' || getline(nextnonblank(v:lnum+1)) =~# '^\s*Feature:' || indent(prevnonblank(v:lnum-1)) <= 0)
+ return 0
+ elseif line =~# '^\s*@'
+ return &sw
+ elseif cline =~# '^\s*|' && line =~# '^\s*|'
+ return indent(prevnonblank(v:lnum-1))
+ elseif cline =~# '^\s*|' && line =~# '^\s*[^|#]'
+ return indent(prevnonblank(v:lnum-1)) + &sw
+ elseif cline =~# '^\s*[^|# \t]' && line =~# '^\s*|'
+ return indent(prevnonblank(v:lnum-1)) - &sw
+ elseif cline =~# '^\s*$' && line =~# '^\s*|'
+ let in = indent(prevnonblank(v:lnum-1))
+ return in == indent(v:lnum) ? in : in - &sw
+ elseif cline =~# '^\s*#' && getline(v:lnum-1) =~ '^\s*$' && getline(v:lnum+1) =~# '\S'
+ return indent(getline(v:lnum+1))
+ endif
+ return indent(prevnonblank(v:lnum-1))
+endfunction
+
+" vim:set sts=2 sw=2:
Oops, something went wrong.

0 comments on commit a3351c8

Please sign in to comment.