@@ -29,8 +29,10 @@ if exists("*GetRustIndent")
29
29
finish
30
30
endif
31
31
32
+ " vint: -ProhibitAbbreviationOption
32
33
let s: save_cpo = &cpo
33
34
set cpo &vim
35
+ " vint: +ProhibitAbbreviationOption
34
36
35
37
" Come here when loading the script the first time.
36
38
@@ -44,12 +46,12 @@ function! s:get_line_trimmed(lnum)
44
46
" If the last character in the line is a comment, do a binary search for
45
47
" the start of the comment. synID() is slow, a linear search would take
46
48
" too long on a long line.
47
- if synIDattr (synID (a: lnum , line_len, 1 ), " name" ) = ~ ' Comment\|Todo'
49
+ if synIDattr (synID (a: lnum , line_len, 1 ), " name" ) = ~? ' Comment\|Todo'
48
50
let min = 1
49
51
let max = line_len
50
52
while min < max
51
53
let col = (min + max ) / 2
52
- if synIDattr (synID (a: lnum , col , 1 ), " name" ) = ~ ' Comment\|Todo'
54
+ if synIDattr (synID (a: lnum , col , 1 ), " name" ) = ~? ' Comment\|Todo'
53
55
let max = col
54
56
else
55
57
let min = col + 1
@@ -69,7 +71,7 @@ function! s:is_string_comment(lnum, col)
69
71
if has (' syntax_items' )
70
72
for id in synstack (a: lnum , a: col )
71
73
let synname = synIDattr (id, " name" )
72
- if synname == " rustString" || synname = ~ " ^rustComment"
74
+ if synname == # " rustString" || synname = ~# " ^rustComment"
73
75
return 1
74
76
endif
75
77
endfor
@@ -88,13 +90,13 @@ function GetRustIndent(lnum)
88
90
89
91
if has (' syntax_items' )
90
92
let synname = synIDattr (synID (a: lnum , 1 , 1 ), " name" )
91
- if synname == " rustString"
93
+ if synname == # " rustString"
92
94
" If the start of the line is in a string, don't change the indent
93
95
return -1
94
- elseif synname = ~ ' \(Comment\|Todo\)'
95
- \ && line !~ ' ^\s*/\*' " not /* opening line
96
- if synname = ~ " CommentML" " multi-line
97
- if line !~ ' ^\s*\*' && getline (a: lnum - 1 ) = ~ ' ^\s*/\*'
96
+ elseif synname = ~? ' \(Comment\|Todo\)'
97
+ \ && line !~# ' ^\s*/\*' " not /* opening line
98
+ if synname = ~? " CommentML" " multi-line
99
+ if line !~# ' ^\s*\*' && getline (a: lnum - 1 ) = ~# ' ^\s*/\*'
98
100
" This is (hopefully) the line after a /*, and it has no
99
101
" leader, so the correct indentation is that of the
100
102
" previous line.
@@ -121,22 +123,22 @@ function GetRustIndent(lnum)
121
123
" Search backwards for the previous non-empty line.
122
124
let prevlinenum = prevnonblank (a: lnum - 1 )
123
125
let prevline = s: get_line_trimmed (prevlinenum)
124
- while prevlinenum > 1 && prevline !~ ' [^[:blank:]]'
126
+ while prevlinenum > 1 && prevline !~# ' [^[:blank:]]'
125
127
let prevlinenum = prevnonblank (prevlinenum - 1 )
126
128
let prevline = s: get_line_trimmed (prevlinenum)
127
129
endwhile
128
130
129
131
" Handle where clauses nicely: subsequent values should line up nicely.
130
- if prevline[len (prevline) - 1 ] == " ,"
132
+ if prevline[len (prevline) - 1 ] == # " ,"
131
133
\ && prevline = ~# ' ^\s*where\s'
132
134
return indent (prevlinenum) + 6
133
135
endif
134
136
135
- if prevline[len (prevline) - 1 ] == " ,"
136
- \ && s: get_line_trimmed (a: lnum ) !~ ' ^\s*[\[\]{}]'
137
- \ && prevline !~ ' ^\s*fn\s'
138
- \ && prevline !~ ' ([^()]\+,$'
139
- \ && s: get_line_trimmed (a: lnum ) !~ ' ^\s*\S\+\s*=>'
137
+ if prevline[len (prevline) - 1 ] == # " ,"
138
+ \ && s: get_line_trimmed (a: lnum ) !~# ' ^\s*[\[\]{}]'
139
+ \ && prevline !~# ' ^\s*fn\s'
140
+ \ && prevline !~# ' ([^()]\+,$'
141
+ \ && s: get_line_trimmed (a: lnum ) !~# ' ^\s*\S\+\s*=>'
140
142
" Oh ho! The previous line ended in a comma! I bet cindent will try to
141
143
" take this too far... For now, let's normally use the previous line's
142
144
" indent.
@@ -195,7 +197,7 @@ function GetRustIndent(lnum)
195
197
else
196
198
" At the module scope, inside square brackets only
197
199
" if getline(a:lnum)[0] == ']' || search('\[', '', '\]', 'nW') == a:lnum
198
- if line = ~ " ^\\ s*]"
200
+ if line = ~# " ^\\ s*]"
199
201
" It's the closing line, dedent it
200
202
return 0
201
203
else
@@ -209,7 +211,9 @@ function GetRustIndent(lnum)
209
211
return cindent (a: lnum )
210
212
endfunction
211
213
214
+ " vint: -ProhibitAbbreviationOption
212
215
let &cpo = s: save_cpo
213
216
unlet s: save_cpo
217
+ " vint: +ProhibitAbbreviationOption
214
218
215
219
" vim: set et sw = 4 sts = 4 ts = 8 :
0 commit comments