@@ -29,8 +29,10 @@ if exists("*GetRustIndent")
2929 finish
3030endif
3131
32+ " vint: -ProhibitAbbreviationOption
3233let s: save_cpo = &cpo
3334set cpo &vim
35+ " vint: +ProhibitAbbreviationOption
3436
3537" Come here when loading the script the first time.
3638
@@ -44,12 +46,12 @@ function! s:get_line_trimmed(lnum)
4446 " If the last character in the line is a comment, do a binary search for
4547 " the start of the comment. synID() is slow, a linear search would take
4648 " 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'
4850 let min = 1
4951 let max = line_len
5052 while min < max
5153 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'
5355 let max = col
5456 else
5557 let min = col + 1
@@ -69,7 +71,7 @@ function! s:is_string_comment(lnum, col)
6971 if has (' syntax_items' )
7072 for id in synstack (a: lnum , a: col )
7173 let synname = synIDattr (id, " name" )
72- if synname == " rustString" || synname = ~ " ^rustComment"
74+ if synname == # " rustString" || synname = ~# " ^rustComment"
7375 return 1
7476 endif
7577 endfor
@@ -88,13 +90,13 @@ function GetRustIndent(lnum)
8890
8991 if has (' syntax_items' )
9092 let synname = synIDattr (synID (a: lnum , 1 , 1 ), " name" )
91- if synname == " rustString"
93+ if synname == # " rustString"
9294 " If the start of the line is in a string, don't change the indent
9395 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*/\*'
98100 " This is (hopefully) the line after a /*, and it has no
99101 " leader, so the correct indentation is that of the
100102 " previous line.
@@ -121,22 +123,22 @@ function GetRustIndent(lnum)
121123 " Search backwards for the previous non-empty line.
122124 let prevlinenum = prevnonblank (a: lnum - 1 )
123125 let prevline = s: get_line_trimmed (prevlinenum)
124- while prevlinenum > 1 && prevline !~ ' [^[:blank:]]'
126+ while prevlinenum > 1 && prevline !~# ' [^[:blank:]]'
125127 let prevlinenum = prevnonblank (prevlinenum - 1 )
126128 let prevline = s: get_line_trimmed (prevlinenum)
127129 endwhile
128130
129131 " Handle where clauses nicely: subsequent values should line up nicely.
130- if prevline[len (prevline) - 1 ] == " ,"
132+ if prevline[len (prevline) - 1 ] == # " ,"
131133 \ && prevline = ~# ' ^\s*where\s'
132134 return indent (prevlinenum) + 6
133135 endif
134136
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*=>'
140142 " Oh ho! The previous line ended in a comma! I bet cindent will try to
141143 " take this too far... For now, let's normally use the previous line's
142144 " indent.
@@ -195,7 +197,7 @@ function GetRustIndent(lnum)
195197 else
196198 " At the module scope, inside square brackets only
197199 " if getline(a:lnum)[0] == ']' || search('\[', '', '\]', 'nW') == a:lnum
198- if line = ~ " ^\\ s*]"
200+ if line = ~# " ^\\ s*]"
199201 " It's the closing line, dedent it
200202 return 0
201203 else
@@ -209,7 +211,9 @@ function GetRustIndent(lnum)
209211 return cindent (a: lnum )
210212endfunction
211213
214+ " vint: -ProhibitAbbreviationOption
212215let &cpo = s: save_cpo
213216unlet s: save_cpo
217+ " vint: +ProhibitAbbreviationOption
214218
215219" vim: set et sw = 4 sts = 4 ts = 8 :
0 commit comments