Mercurial > vim
comparison runtime/indent/cucumber.vim @ 10048:43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Author: Bram Moolenaar <Bram@vim.org>
Date: Tue Aug 30 23:26:57 2016 +0200
Updated runtime files. Remove version checks for Vim older than 6.0.
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Tue, 30 Aug 2016 23:30:09 +0200 |
parents | 2eb30f341e8d |
children | 63b0b7b79b25 |
comparison
equal
deleted
inserted
replaced
10047:a62862410ca1 | 10048:43efa4f5a8ea |
---|---|
1 " Vim indent file | 1 " Vim indent file |
2 " Language: Cucumber | 2 " Language: Cucumber |
3 " Maintainer: Tim Pope <vimNOSPAM@tpope.org> | 3 " Maintainer: Tim Pope <vimNOSPAM@tpope.org> |
4 " Last Change: 2013 May 30 | 4 " Last Change: 2016 Aug 29 |
5 | 5 |
6 if exists("b:did_indent") | 6 if exists("b:did_indent") |
7 finish | 7 finish |
8 endif | 8 endif |
9 let b:did_indent = 1 | 9 let b:did_indent = 1 |
25 | 25 |
26 function! GetCucumberIndent() | 26 function! GetCucumberIndent() |
27 let line = getline(prevnonblank(v:lnum-1)) | 27 let line = getline(prevnonblank(v:lnum-1)) |
28 let cline = getline(v:lnum) | 28 let cline = getline(v:lnum) |
29 let nline = getline(nextnonblank(v:lnum+1)) | 29 let nline = getline(nextnonblank(v:lnum+1)) |
30 let sw = exists('*shiftwidth') ? shiftwidth() : &sw | |
30 let syn = s:syn(prevnonblank(v:lnum-1)) | 31 let syn = s:syn(prevnonblank(v:lnum-1)) |
31 let csyn = s:syn(v:lnum) | 32 let csyn = s:syn(v:lnum) |
32 let nsyn = s:syn(nextnonblank(v:lnum+1)) | 33 let nsyn = s:syn(nextnonblank(v:lnum+1)) |
33 if csyn ==# 'cucumberFeature' || cline =~# '^\s*Feature:' | 34 if csyn ==# 'cucumberFeature' || cline =~# '^\s*Feature:' |
34 " feature heading | 35 " feature heading |
35 return 0 | 36 return 0 |
36 elseif csyn ==# 'cucumberExamples' || cline =~# '^\s*\%(Examples\|Scenarios\):' | 37 elseif csyn ==# 'cucumberExamples' || cline =~# '^\s*\%(Examples\|Scenarios\):' |
37 " examples heading | 38 " examples heading |
38 return 2 * &sw | 39 return 2 * sw |
39 elseif csyn =~# '^cucumber\%(Background\|Scenario\|ScenarioOutline\)$' || cline =~# '^\s*\%(Background\|Scenario\|Scenario Outline\):' | 40 elseif csyn =~# '^cucumber\%(Background\|Scenario\|ScenarioOutline\)$' || cline =~# '^\s*\%(Background\|Scenario\|Scenario Outline\):' |
40 " background, scenario or outline heading | 41 " background, scenario or outline heading |
41 return &sw | 42 return sw |
42 elseif syn ==# 'cucumberFeature' || line =~# '^\s*Feature:' | 43 elseif syn ==# 'cucumberFeature' || line =~# '^\s*Feature:' |
43 " line after feature heading | 44 " line after feature heading |
44 return &sw | 45 return sw |
45 elseif syn ==# 'cucumberExamples' || line =~# '^\s*\%(Examples\|Scenarios\):' | 46 elseif syn ==# 'cucumberExamples' || line =~# '^\s*\%(Examples\|Scenarios\):' |
46 " line after examples heading | 47 " line after examples heading |
47 return 3 * &sw | 48 return 3 * sw |
48 elseif syn =~# '^cucumber\%(Background\|Scenario\|ScenarioOutline\)$' || line =~# '^\s*\%(Background\|Scenario\|Scenario Outline\):' | 49 elseif syn =~# '^cucumber\%(Background\|Scenario\|ScenarioOutline\)$' || line =~# '^\s*\%(Background\|Scenario\|Scenario Outline\):' |
49 " line after background, scenario or outline heading | 50 " line after background, scenario or outline heading |
50 return 2 * &sw | 51 return 2 * sw |
51 elseif cline =~# '^\s*[@#]' && (nsyn == 'cucumberFeature' || nline =~# '^\s*Feature:' || indent(prevnonblank(v:lnum-1)) <= 0) | 52 elseif cline =~# '^\s*[@#]' && (nsyn == 'cucumberFeature' || nline =~# '^\s*Feature:' || indent(prevnonblank(v:lnum-1)) <= 0) |
52 " tag or comment before a feature heading | 53 " tag or comment before a feature heading |
53 return 0 | 54 return 0 |
54 elseif cline =~# '^\s*@' | 55 elseif cline =~# '^\s*@' |
55 " other tags | 56 " other tags |
56 return &sw | 57 return sw |
57 elseif cline =~# '^\s*[#|]' && line =~# '^\s*|' | 58 elseif cline =~# '^\s*[#|]' && line =~# '^\s*|' |
58 " mid-table | 59 " mid-table |
59 " preserve indent | 60 " preserve indent |
60 return indent(prevnonblank(v:lnum-1)) | 61 return indent(prevnonblank(v:lnum-1)) |
61 elseif cline =~# '^\s*|' && line =~# '^\s*[^|]' | 62 elseif cline =~# '^\s*|' && line =~# '^\s*[^|]' |
62 " first line of a table, relative indent | 63 " first line of a table, relative indent |
63 return indent(prevnonblank(v:lnum-1)) + &sw | 64 return indent(prevnonblank(v:lnum-1)) + sw |
64 elseif cline =~# '^\s*[^|]' && line =~# '^\s*|' | 65 elseif cline =~# '^\s*[^|]' && line =~# '^\s*|' |
65 " line after a table, relative unindent | 66 " line after a table, relative unindent |
66 return indent(prevnonblank(v:lnum-1)) - &sw | 67 return indent(prevnonblank(v:lnum-1)) - sw |
67 elseif cline =~# '^\s*#' && getline(v:lnum-1) =~ '^\s*$' && (nsyn =~# '^cucumber\%(Background\|Scenario\|ScenarioOutline\)$' || nline =~# '^\s*\%(Background\|Scenario\|Scenario Outline\):') | 68 elseif cline =~# '^\s*#' && getline(v:lnum-1) =~ '^\s*$' && (nsyn =~# '^cucumber\%(Background\|Scenario\|ScenarioOutline\)$' || nline =~# '^\s*\%(Background\|Scenario\|Scenario Outline\):') |
68 " comments on scenarios | 69 " comments on scenarios |
69 return &sw | 70 return sw |
70 endif | 71 endif |
71 return indent(prevnonblank(v:lnum-1)) | 72 return indent(prevnonblank(v:lnum-1)) |
72 endfunction | 73 endfunction |
73 | 74 |
74 " vim:set sts=2 sw=2: | 75 " vim:set sts=2 sw=2: |