@@ -18,6 +18,7 @@ let s:named_module_entry = '\v^\s*-\s*(name|hosts|role):\s*\S' " - name: 'do stu
18
18
let s: dictionary_entry = ' \v^\s*[^:-]+:\s*$' " with_items:
19
19
let s: key_value = ' \v^\s*[^:-]+:\s*\S' " apt: name=package
20
20
let s: scalar_value = ' \v:\s*[>|\|]\s*$' " shell: >
21
+ let s: blank = ' \v^\s*$' " line with only spaces
21
22
22
23
if exists (' *GetAnsibleIndent' )
23
24
finish
@@ -33,26 +34,29 @@ function GetAnsibleIndent(lnum)
33
34
endif
34
35
endif
35
36
let prevlnum = prevnonblank (a: lnum - 1 )
36
- let maintain = indent (prevlnum )
37
- let increase = maintain + &sw
37
+ let default = GetYAMLIndent ( a: lnum )
38
+ let increase = indent (prevlnum) + &sw
38
39
39
- let line = getline (prevlnum)
40
- if line = ~ s: array_entry
41
- if line = ~ s: named_module_entry
40
+ let prevline = getline (prevlnum)
41
+ let line = getline (a: lnum )
42
+ if line !~ s: blank
43
+ return default " we only special case blank lines
44
+ elseif prevline = ~ s: array_entry
45
+ if prevline = ~ s: named_module_entry
42
46
return increase
43
47
else
44
- return maintain
48
+ return default
45
49
endif
46
- elseif line = ~ s: dictionary_entry
50
+ elseif prevline = ~ s: dictionary_entry
47
51
return increase
48
- elseif line = ~ s: key_value
49
- if line = ~ s: scalar_value
52
+ elseif prevline = ~ s: key_value
53
+ if prevline = ~ s: scalar_value
50
54
return increase
51
55
else
52
- return maintain
56
+ return default
53
57
endif
54
58
else
55
- return maintain
59
+ return default
56
60
endif
57
61
endfunction
58
62
0 commit comments