vint: Use =~#
This commit is contained in:
parent
5cff46c7d5
commit
7cead42bb1
1 changed files with 13 additions and 13 deletions
|
|
@ -38,7 +38,7 @@ function! GetNimIndent(lnum)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" If the start of the line is in a string don't change the indent.
|
" If the start of the line is in a string don't change the indent.
|
||||||
if has('syntax_items') && synIDattr(synID(a:lnum, 1, 1), 'name') =~ 'String$'
|
if has('syntax_items') && synIDattr(synID(a:lnum, 1, 1), 'name') =~# 'String$'
|
||||||
return -1
|
return -1
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
@ -54,12 +54,12 @@ function! GetNimIndent(lnum)
|
||||||
" If the last character in the line is a comment, do a binary search for
|
" If the last character in the line is a comment, do a binary search for
|
||||||
" the start of the comment. synID() is slow, a linear search would take
|
" the start of the comment. synID() is slow, a linear search would take
|
||||||
" too long on a long line.
|
" too long on a long line.
|
||||||
if synIDattr(synID(plnum, pline_len, 1), 'name') =~ 'Comment$'
|
if synIDattr(synID(plnum, pline_len, 1), 'name') =~# 'Comment$'
|
||||||
let min = 1
|
let min = 1
|
||||||
let max = pline_len
|
let max = pline_len
|
||||||
while min < max
|
while min < max
|
||||||
let col = (min + max) / 2
|
let col = (min + max) / 2
|
||||||
if synIDattr(synID(plnum, col, 1), 'name') =~ 'Comment$'
|
if synIDattr(synID(plnum, col, 1), 'name') =~# 'Comment$'
|
||||||
let max = col
|
let max = col
|
||||||
else
|
else
|
||||||
let min = col + 1
|
let min = col + 1
|
||||||
|
|
@ -78,16 +78,16 @@ function! GetNimIndent(lnum)
|
||||||
endwhile
|
endwhile
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if cline =~ '^\s*\(if\|when\|for\|while\|case\|of\|try\)\>'
|
if cline =~# '^\s*\(if\|when\|for\|while\|case\|of\|try\)\>'
|
||||||
" This is a benign line, do nothing
|
" This is a benign line, do nothing
|
||||||
return -1
|
return -1
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" If the current line begins with a keyword that lines up with "try"
|
" If the current line begins with a keyword that lines up with "try"
|
||||||
if cline =~ '^\s*\(except\|finally\)\>'
|
if cline =~# '^\s*\(except\|finally\)\>'
|
||||||
let lnum = a:lnum - 1
|
let lnum = a:lnum - 1
|
||||||
while lnum >= 1
|
while lnum >= 1
|
||||||
if getline(lnum) =~ '^\s*\(try\|except\)\>'
|
if getline(lnum) =~# '^\s*\(try\|except\)\>'
|
||||||
let ind = indent(lnum)
|
let ind = indent(lnum)
|
||||||
if ind >= clindent
|
if ind >= clindent
|
||||||
return -1 " indent is already less than this
|
return -1 " indent is already less than this
|
||||||
|
|
@ -100,31 +100,31 @@ function! GetNimIndent(lnum)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" If the current line begins with a header keyword, dedent
|
" If the current line begins with a header keyword, dedent
|
||||||
if cline =~ '^\s*\(elif\|else\)\>'
|
if cline =~# '^\s*\(elif\|else\)\>'
|
||||||
return s:FindStartLine(a:lnum, '^\s*\(if\|when\|elif\|of\)')
|
return s:FindStartLine(a:lnum, '^\s*\(if\|when\|elif\|of\)')
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if pline =~ ':\s*$'
|
if pline =~# ':\s*$'
|
||||||
"return s:FindStartLine(plnum, '(^\s*\(if\|when\|else\|elif\|case\|of\|try\|except\|finally\)\>)\|\<do\>') + &sw
|
"return s:FindStartLine(plnum, '(^\s*\(if\|when\|else\|elif\|case\|of\|try\|except\|finally\)\>)\|\<do\>') + &sw
|
||||||
return s:FindStartLine(plnum, '^\s*\(if\|when\|else\|elif\|for\|while\|case\|of\|try\|except\|finally\)\>') + &sw
|
return s:FindStartLine(plnum, '^\s*\(if\|when\|else\|elif\|for\|while\|case\|of\|try\|except\|finally\)\>') + &sw
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if pline =~ '=\s*$'
|
if pline =~# '=\s*$'
|
||||||
return s:FindStartLine(plnum, '^\s*\(proc\|template\|macro\|iterator\)\>') + &sw
|
return s:FindStartLine(plnum, '^\s*\(proc\|template\|macro\|iterator\)\>') + &sw
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" if we got here, this should be the begging of a multi-line if expression for example
|
" if we got here, this should be the begging of a multi-line if expression for example
|
||||||
if pline =~ '^\s*\(if\|when\|proc\|iterator\|macro\|template\|for\|while\)[^:]*$'
|
if pline =~# '^\s*\(if\|when\|proc\|iterator\|macro\|template\|for\|while\)[^:]*$'
|
||||||
return plindent + &sw
|
return plindent + &sw
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if pline =~ '\(type\|import\|const\|var\|let\)\s*$'
|
if pline =~# '\(type\|import\|const\|var\|let\)\s*$'
|
||||||
\ || pline =~ '=\s*\(object\|enum\|tuple\|concept\)'
|
\ || pline =~# '=\s*\(object\|enum\|tuple\|concept\)'
|
||||||
return plindent + &sw
|
return plindent + &sw
|
||||||
endif
|
endif
|
||||||
|
|
||||||
" If the previous line was a stop-execution statement...
|
" If the previous line was a stop-execution statement...
|
||||||
if pline =~ '^\s*\(break\|continue\|raise\|return\)\>'
|
if pline =~# '^\s*\(break\|continue\|raise\|return\)\>'
|
||||||
" See if the user has already dedented
|
" See if the user has already dedented
|
||||||
if indent(a:lnum) > plindent - &sw
|
if indent(a:lnum) > plindent - &sw
|
||||||
" If not, recommend one dedent
|
" If not, recommend one dedent
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue