Mercurial > vim
annotate runtime/indent/cucumber.vim @ 20907:4eeda7139133 v8.2.1005
patch 8.2.1005: Vim9: using TRUE/FALSE/MAYBE for ctx_skip is confusing
Commit: https://github.com/vim/vim/commit/9b68c82b7ca768100f3eb4223d100c62c5429e53
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Jun 18 19:31:08 2020 +0200
patch 8.2.1005: Vim9: using TRUE/FALSE/MAYBE for ctx_skip is confusing
Problem: Vim9: using TRUE/FALSE/MAYBE for ctx_skip is confusing.
Solution: Use an enum value.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 18 Jun 2020 19:45:03 +0200 |
parents | 63b0b7b79b25 |
children | 9ece16460769 |
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> |
11518 | 4 " Last Change: 2017 Jun 13 |
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 |
4681
2eb30f341e8d
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2202
diff
changeset
|
15 let b:undo_indent = 'setl ai< inde< indk<' |
2eb30f341e8d
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2202
diff
changeset
|
16 |
2098
3259c3923c1e
Updated runtime an documentation files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff
changeset
|
17 " Only define the function once. |
3259c3923c1e
Updated runtime an documentation files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff
changeset
|
18 if exists("*GetCucumberIndent") |
3259c3923c1e
Updated runtime an documentation files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff
changeset
|
19 finish |
3259c3923c1e
Updated runtime an documentation files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff
changeset
|
20 endif |
3259c3923c1e
Updated runtime an documentation files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff
changeset
|
21 |
3259c3923c1e
Updated runtime an documentation files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff
changeset
|
22 function! s:syn(lnum) |
3259c3923c1e
Updated runtime an documentation files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff
changeset
|
23 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
|
24 endfunction |
3259c3923c1e
Updated runtime an documentation files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff
changeset
|
25 |
3259c3923c1e
Updated runtime an documentation files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff
changeset
|
26 function! GetCucumberIndent() |
3259c3923c1e
Updated runtime an documentation files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff
changeset
|
27 let line = getline(prevnonblank(v:lnum-1)) |
3259c3923c1e
Updated runtime an documentation files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff
changeset
|
28 let cline = getline(v:lnum) |
4681
2eb30f341e8d
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2202
diff
changeset
|
29 let nline = getline(nextnonblank(v:lnum+1)) |
11518 | 30 let sw = exists('*shiftwidth') ? shiftwidth() : shiftwidth() |
2098
3259c3923c1e
Updated runtime an documentation files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff
changeset
|
31 let syn = s:syn(prevnonblank(v:lnum-1)) |
3259c3923c1e
Updated runtime an documentation files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff
changeset
|
32 let csyn = s:syn(v:lnum) |
4681
2eb30f341e8d
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2202
diff
changeset
|
33 let nsyn = s:syn(nextnonblank(v:lnum+1)) |
2098
3259c3923c1e
Updated runtime an documentation files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff
changeset
|
34 if csyn ==# 'cucumberFeature' || cline =~# '^\s*Feature:' |
4681
2eb30f341e8d
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2202
diff
changeset
|
35 " feature heading |
2098
3259c3923c1e
Updated runtime an documentation files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff
changeset
|
36 return 0 |
3259c3923c1e
Updated runtime an documentation files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff
changeset
|
37 elseif csyn ==# 'cucumberExamples' || cline =~# '^\s*\%(Examples\|Scenarios\):' |
4681
2eb30f341e8d
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2202
diff
changeset
|
38 " examples heading |
10048
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4681
diff
changeset
|
39 return 2 * sw |
2098
3259c3923c1e
Updated runtime an documentation files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff
changeset
|
40 elseif csyn =~# '^cucumber\%(Background\|Scenario\|ScenarioOutline\)$' || cline =~# '^\s*\%(Background\|Scenario\|Scenario Outline\):' |
4681
2eb30f341e8d
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2202
diff
changeset
|
41 " background, scenario or outline heading |
10048
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4681
diff
changeset
|
42 return sw |
2098
3259c3923c1e
Updated runtime an documentation files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff
changeset
|
43 elseif syn ==# 'cucumberFeature' || line =~# '^\s*Feature:' |
4681
2eb30f341e8d
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2202
diff
changeset
|
44 " line after feature heading |
10048
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4681
diff
changeset
|
45 return sw |
2098
3259c3923c1e
Updated runtime an documentation files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff
changeset
|
46 elseif syn ==# 'cucumberExamples' || line =~# '^\s*\%(Examples\|Scenarios\):' |
4681
2eb30f341e8d
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2202
diff
changeset
|
47 " line after examples heading |
10048
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4681
diff
changeset
|
48 return 3 * sw |
2098
3259c3923c1e
Updated runtime an documentation files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff
changeset
|
49 elseif syn =~# '^cucumber\%(Background\|Scenario\|ScenarioOutline\)$' || line =~# '^\s*\%(Background\|Scenario\|Scenario Outline\):' |
4681
2eb30f341e8d
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2202
diff
changeset
|
50 " line after background, scenario or outline heading |
10048
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4681
diff
changeset
|
51 return 2 * sw |
4681
2eb30f341e8d
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2202
diff
changeset
|
52 elseif cline =~# '^\s*[@#]' && (nsyn == 'cucumberFeature' || nline =~# '^\s*Feature:' || indent(prevnonblank(v:lnum-1)) <= 0) |
2eb30f341e8d
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2202
diff
changeset
|
53 " tag or comment before a feature heading |
2098
3259c3923c1e
Updated runtime an documentation files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff
changeset
|
54 return 0 |
4681
2eb30f341e8d
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2202
diff
changeset
|
55 elseif cline =~# '^\s*@' |
2eb30f341e8d
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2202
diff
changeset
|
56 " other tags |
10048
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4681
diff
changeset
|
57 return sw |
4681
2eb30f341e8d
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2202
diff
changeset
|
58 elseif cline =~# '^\s*[#|]' && line =~# '^\s*|' |
2eb30f341e8d
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2202
diff
changeset
|
59 " mid-table |
2eb30f341e8d
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2202
diff
changeset
|
60 " preserve indent |
2098
3259c3923c1e
Updated runtime an documentation files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff
changeset
|
61 return indent(prevnonblank(v:lnum-1)) |
4681
2eb30f341e8d
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2202
diff
changeset
|
62 elseif cline =~# '^\s*|' && line =~# '^\s*[^|]' |
2eb30f341e8d
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2202
diff
changeset
|
63 " first line of a table, relative indent |
10048
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4681
diff
changeset
|
64 return indent(prevnonblank(v:lnum-1)) + sw |
4681
2eb30f341e8d
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2202
diff
changeset
|
65 elseif cline =~# '^\s*[^|]' && line =~# '^\s*|' |
2eb30f341e8d
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2202
diff
changeset
|
66 " line after a table, relative unindent |
10048
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4681
diff
changeset
|
67 return indent(prevnonblank(v:lnum-1)) - sw |
4681
2eb30f341e8d
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2202
diff
changeset
|
68 elseif cline =~# '^\s*#' && getline(v:lnum-1) =~ '^\s*$' && (nsyn =~# '^cucumber\%(Background\|Scenario\|ScenarioOutline\)$' || nline =~# '^\s*\%(Background\|Scenario\|Scenario Outline\):') |
2eb30f341e8d
Updated runtime files and translations.
Bram Moolenaar <bram@vim.org>
parents:
2202
diff
changeset
|
69 " comments on scenarios |
10048
43efa4f5a8ea
commit https://github.com/vim/vim/commit/89bcfda6834aba724d12554a34b9ed49f5789fd5
Christian Brabandt <cb@256bit.org>
parents:
4681
diff
changeset
|
70 return sw |
2098
3259c3923c1e
Updated runtime an documentation files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff
changeset
|
71 endif |
3259c3923c1e
Updated runtime an documentation files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff
changeset
|
72 return indent(prevnonblank(v:lnum-1)) |
3259c3923c1e
Updated runtime an documentation files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff
changeset
|
73 endfunction |
3259c3923c1e
Updated runtime an documentation files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff
changeset
|
74 |
3259c3923c1e
Updated runtime an documentation files.
Bram Moolenaar <bram@zimbu.org>
parents:
diff
changeset
|
75 " vim:set sts=2 sw=2: |