@@ -10,7 +10,7 @@ let b:did_indent = 1
10
10
11
11
setlocal nosmartindent
12
12
13
- setlocal indentexpr = GetElixirIndent (v: lnum )
13
+ setlocal indentexpr = GetElixirIndent ()
14
14
setlocal indentkeys += = end ,= else :,= match :,= elsif:,= catch :,= after:,= rescue:
15
15
16
16
if exists (" *GetElixirIndent" )
@@ -31,7 +31,7 @@ let s:pipeline = '^\s*|>.*$'
31
31
let s: indent_keywords = ' \<\%(' . s: block_start . ' \|' . s: block_middle . ' \)$' . ' \|' . s: arrow
32
32
let s: deindent_keywords = ' ^\s*\<\%(' . s: block_end . ' \|' . s: block_middle . ' \)\>' . ' \|' . s: arrow
33
33
34
- function ! GetElixirIndent (... )
34
+ function ! GetElixirIndent ()
35
35
let lnum = prevnonblank (v: lnum - 1 )
36
36
let ind = indent (lnum)
37
37
@@ -40,6 +40,14 @@ function! GetElixirIndent(...)
40
40
return 0
41
41
endif
42
42
43
+ " TODO: Remove these 2 lines
44
+ " I don't know why, but for the test on spec/indent/lists_spec.rb:24.
45
+ " Vim is making some mess on parsing the syntax of 'end', it is being
46
+ " recognized as 'elixirString' when should be recognized as 'elixirBlock'.
47
+ " This forces vim to sync the syntax.
48
+ call synID (v: lnum , 1 , 1 )
49
+ syntax sync fromstart
50
+
43
51
if synIDattr (synID (v: lnum , 1 , 1 ), " name" ) !~ s: skip_syntax
44
52
let current_line = getline (v: lnum )
45
53
let last_line = getline (lnum)
@@ -61,7 +69,7 @@ function! GetElixirIndent(...)
61
69
if current_line = ~ s: pipeline &&
62
70
\ last_line = ~ ' ^[^=]\+=.\+$'
63
71
let b: old_ind = ind
64
- let ind += round ( match (last_line, ' =' ) / &sw ) * &sw
72
+ let ind = float2nr ( matchend (last_line, ' =\s*[^ ] ' ) / &sw ) * &sw
65
73
endif
66
74
67
75
" if last line starts with pipeline
@@ -78,6 +86,7 @@ function! GetElixirIndent(...)
78
86
\ ' \<:\@<!' . s: block_end . ' \>\zs' ,
79
87
\ ' nbW' ,
80
88
\ s: block_skip )
89
+
81
90
let ind = indent (bslnum)
82
91
endif
83
92
0 commit comments