annotate runtime/indent/cucumber.vim @ 4676:9d3768ec9d74

Added tag v7-3-1085 for changeset 811a4c9b51d8
author Bram Moolenaar <bram@vim.org>
date Sat, 01 Jun 2013 12:40:20 +0200
parents f7579a31705c
children 2eb30f341e8d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2098
3259c3923c1e Updated runtime an documentation files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
1 " Vim indent file
3259c3923c1e Updated runtime an documentation files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
2 " Language: Cucumber
3259c3923c1e Updated runtime an documentation files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
3 " Maintainer: Tim Pope <vimNOSPAM@tpope.org>
2202
f7579a31705c Updated runtime files.
Bram Moolenaar <bram@vim.org>
parents: 2098
diff changeset
4 " Last Change: 2010 May 21
2098
3259c3923c1e Updated runtime an documentation files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
5
3259c3923c1e Updated runtime an documentation files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
6 if exists("b:did_indent")
3259c3923c1e Updated runtime an documentation files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
7 finish
3259c3923c1e Updated runtime an documentation files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
8 endif
3259c3923c1e Updated runtime an documentation files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
9 let b:did_indent = 1
3259c3923c1e Updated runtime an documentation files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
10
3259c3923c1e Updated runtime an documentation files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
11 setlocal autoindent
3259c3923c1e Updated runtime an documentation files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
12 setlocal indentexpr=GetCucumberIndent()
3259c3923c1e Updated runtime an documentation files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
13 setlocal indentkeys=o,O,*<Return>,<:>,0<Bar>,0#,=,!^F
3259c3923c1e Updated runtime an documentation files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
14
3259c3923c1e Updated runtime an documentation files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
15 " Only define the function once.
3259c3923c1e Updated runtime an documentation files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
16 if exists("*GetCucumberIndent")
3259c3923c1e Updated runtime an documentation files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
17 finish
3259c3923c1e Updated runtime an documentation files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
18 endif
3259c3923c1e Updated runtime an documentation files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
19
3259c3923c1e Updated runtime an documentation files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
20 function! s:syn(lnum)
3259c3923c1e Updated runtime an documentation files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
21 return synIDattr(synID(a:lnum,1+indent(a:lnum),1),'name')
3259c3923c1e Updated runtime an documentation files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
22 endfunction
3259c3923c1e Updated runtime an documentation files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
23
3259c3923c1e Updated runtime an documentation files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
24 function! GetCucumberIndent()
3259c3923c1e Updated runtime an documentation files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
25 let line = getline(prevnonblank(v:lnum-1))
3259c3923c1e Updated runtime an documentation files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
26 let cline = getline(v:lnum)
3259c3923c1e Updated runtime an documentation files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
27 let syn = s:syn(prevnonblank(v:lnum-1))
3259c3923c1e Updated runtime an documentation files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
28 let csyn = s:syn(v:lnum)
3259c3923c1e Updated runtime an documentation files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
29 if csyn ==# 'cucumberFeature' || cline =~# '^\s*Feature:'
3259c3923c1e Updated runtime an documentation files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
30 return 0
3259c3923c1e Updated runtime an documentation files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
31 elseif csyn ==# 'cucumberExamples' || cline =~# '^\s*\%(Examples\|Scenarios\):'
3259c3923c1e Updated runtime an documentation files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
32 return 2 * &sw
3259c3923c1e Updated runtime an documentation files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
33 elseif csyn =~# '^cucumber\%(Background\|Scenario\|ScenarioOutline\)$' || cline =~# '^\s*\%(Background\|Scenario\|Scenario Outline\):'
3259c3923c1e Updated runtime an documentation files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
34 return &sw
3259c3923c1e Updated runtime an documentation files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
35 elseif syn ==# 'cucumberFeature' || line =~# '^\s*Feature:'
3259c3923c1e Updated runtime an documentation files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
36 return &sw
3259c3923c1e Updated runtime an documentation files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
37 elseif syn ==# 'cucumberExamples' || line =~# '^\s*\%(Examples\|Scenarios\):'
3259c3923c1e Updated runtime an documentation files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
38 return 3 * &sw
3259c3923c1e Updated runtime an documentation files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
39 elseif syn =~# '^cucumber\%(Background\|Scenario\|ScenarioOutline\)$' || line =~# '^\s*\%(Background\|Scenario\|Scenario Outline\):'
3259c3923c1e Updated runtime an documentation files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
40 return 2 * &sw
3259c3923c1e Updated runtime an documentation files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
41 elseif cline =~# '^\s*@' && (s:syn(nextnonblank(v:lnum+1)) == 'cucumberFeature' || getline(nextnonblank(v:lnum+1)) =~# '^\s*Feature:' || indent(prevnonblank(v:lnum-1)) <= 0)
3259c3923c1e Updated runtime an documentation files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
42 return 0
3259c3923c1e Updated runtime an documentation files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
43 elseif line =~# '^\s*@'
3259c3923c1e Updated runtime an documentation files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
44 return &sw
3259c3923c1e Updated runtime an documentation files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
45 elseif cline =~# '^\s*|' && line =~# '^\s*|'
3259c3923c1e Updated runtime an documentation files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
46 return indent(prevnonblank(v:lnum-1))
3259c3923c1e Updated runtime an documentation files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
47 elseif cline =~# '^\s*|' && line =~# '^\s*[^|#]'
3259c3923c1e Updated runtime an documentation files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
48 return indent(prevnonblank(v:lnum-1)) + &sw
3259c3923c1e Updated runtime an documentation files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
49 elseif cline =~# '^\s*[^|# \t]' && line =~# '^\s*|'
3259c3923c1e Updated runtime an documentation files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
50 return indent(prevnonblank(v:lnum-1)) - &sw
3259c3923c1e Updated runtime an documentation files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
51 elseif cline =~# '^\s*$' && line =~# '^\s*|'
3259c3923c1e Updated runtime an documentation files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
52 let in = indent(prevnonblank(v:lnum-1))
3259c3923c1e Updated runtime an documentation files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
53 return in == indent(v:lnum) ? in : in - &sw
3259c3923c1e Updated runtime an documentation files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
54 elseif cline =~# '^\s*#' && getline(v:lnum-1) =~ '^\s*$' && getline(v:lnum+1) =~# '\S'
3259c3923c1e Updated runtime an documentation files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
55 return indent(getline(v:lnum+1))
3259c3923c1e Updated runtime an documentation files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
56 endif
3259c3923c1e Updated runtime an documentation files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
57 return indent(prevnonblank(v:lnum-1))
3259c3923c1e Updated runtime an documentation files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
58 endfunction
3259c3923c1e Updated runtime an documentation files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
59
3259c3923c1e Updated runtime an documentation files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff changeset
60 " vim:set sts=2 sw=2: