diff options
author | Bram Moolenaar <Bram@vim.org> | 2013-06-01 14:50:56 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2013-06-01 14:50:56 +0200 |
commit | 543b7ef7000d08d77409478315d68b607bb8bad8 (patch) | |
tree | 387cd45294ce55a130556d4e22a0b7706156b1fd /runtime/indent/cucumber.vim | |
parent | 3737fc1c30a559c82c57b5ce6aedae76cbeabaef (diff) |
Updated runtime files and translations.
Diffstat (limited to 'runtime/indent/cucumber.vim')
-rw-r--r-- | runtime/indent/cucumber.vim | 36 |
1 files changed, 25 insertions, 11 deletions
diff --git a/runtime/indent/cucumber.vim b/runtime/indent/cucumber.vim index a19d123f7e..965c7786ed 100644 --- a/runtime/indent/cucumber.vim +++ b/runtime/indent/cucumber.vim @@ -1,7 +1,7 @@ " Vim indent file " Language: Cucumber " Maintainer: Tim Pope <vimNOSPAM@tpope.org> -" Last Change: 2010 May 21 +" Last Change: 2013 May 30 if exists("b:did_indent") finish @@ -12,6 +12,8 @@ setlocal autoindent setlocal indentexpr=GetCucumberIndent() setlocal indentkeys=o,O,*<Return>,<:>,0<Bar>,0#,=,!^F +let b:undo_indent = 'setl ai< inde< indk<' + " Only define the function once. if exists("*GetCucumberIndent") finish @@ -24,35 +26,47 @@ endfunction function! GetCucumberIndent() let line = getline(prevnonblank(v:lnum-1)) let cline = getline(v:lnum) + let nline = getline(nextnonblank(v:lnum+1)) let syn = s:syn(prevnonblank(v:lnum-1)) let csyn = s:syn(v:lnum) + let nsyn = s:syn(nextnonblank(v:lnum+1)) if csyn ==# 'cucumberFeature' || cline =~# '^\s*Feature:' + " feature heading return 0 elseif csyn ==# 'cucumberExamples' || cline =~# '^\s*\%(Examples\|Scenarios\):' + " examples heading return 2 * &sw elseif csyn =~# '^cucumber\%(Background\|Scenario\|ScenarioOutline\)$' || cline =~# '^\s*\%(Background\|Scenario\|Scenario Outline\):' + " background, scenario or outline heading return &sw elseif syn ==# 'cucumberFeature' || line =~# '^\s*Feature:' + " line after feature heading return &sw elseif syn ==# 'cucumberExamples' || line =~# '^\s*\%(Examples\|Scenarios\):' + " line after examples heading return 3 * &sw elseif syn =~# '^cucumber\%(Background\|Scenario\|ScenarioOutline\)$' || line =~# '^\s*\%(Background\|Scenario\|Scenario Outline\):' + " line after background, scenario or outline heading 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) + elseif cline =~# '^\s*[@#]' && (nsyn == 'cucumberFeature' || nline =~# '^\s*Feature:' || indent(prevnonblank(v:lnum-1)) <= 0) + " tag or comment before a feature heading return 0 - elseif line =~# '^\s*@' + elseif cline =~# '^\s*@' + " other tags return &sw - elseif cline =~# '^\s*|' && line =~# '^\s*|' + elseif cline =~# '^\s*[#|]' && line =~# '^\s*|' + " mid-table + " preserve indent return indent(prevnonblank(v:lnum-1)) - elseif cline =~# '^\s*|' && line =~# '^\s*[^|#]' + elseif cline =~# '^\s*|' && line =~# '^\s*[^|]' + " first line of a table, relative indent return indent(prevnonblank(v:lnum-1)) + &sw - elseif cline =~# '^\s*[^|# \t]' && line =~# '^\s*|' + elseif cline =~# '^\s*[^|]' && line =~# '^\s*|' + " line after a table, relative unindent 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)) + elseif cline =~# '^\s*#' && getline(v:lnum-1) =~ '^\s*$' && (nsyn =~# '^cucumber\%(Background\|Scenario\|ScenarioOutline\)$' || nline =~# '^\s*\%(Background\|Scenario\|Scenario Outline\):') + " comments on scenarios + return &sw endif return indent(prevnonblank(v:lnum-1)) endfunction |