mirror of
https://github.com/dag/vim-fish
synced 2024-09-16 13:44:02 +02:00
Use shiftwidth()
instead of &shiftwidth
The `shiftwidth` option can be set to 0, in which case the tabstop value is used instead. In order to always set the correct shiftwidth, the Vim docs advise the use of the `shiftwidth()` function.
This commit is contained in:
parent
825853f481
commit
986fcb1e1f
1 changed files with 5 additions and 4 deletions
|
@ -1,4 +1,5 @@
|
|||
function! fish#Indent()
|
||||
let l:shiftwidth = shiftwidth()
|
||||
let l:prevlnum = prevnonblank(v:lnum - 1)
|
||||
if l:prevlnum ==# 0
|
||||
return 0
|
||||
|
@ -6,15 +7,15 @@ function! fish#Indent()
|
|||
let l:indent = 0
|
||||
let l:prevline = getline(l:prevlnum)
|
||||
if l:prevline =~# '\v^\s*switch>'
|
||||
let l:indent = &shiftwidth * 2
|
||||
let l:indent = l:shiftwidth * 2
|
||||
elseif l:prevline =~# '\v^\s*%(begin|if|else|while|for|function|case)>'
|
||||
let l:indent = &shiftwidth
|
||||
let l:indent = l:shiftwidth
|
||||
endif
|
||||
let l:line = getline(v:lnum)
|
||||
if l:line =~# '\v^\s*end>'
|
||||
return indent(v:lnum) - (l:indent ==# 0 ? &shiftwidth : l:indent)
|
||||
return indent(v:lnum) - (l:indent ==# 0 ? l:shiftwidth : l:indent)
|
||||
elseif l:line =~# '\v^\s*%(case|else)>'
|
||||
return indent(v:lnum) - &shiftwidth
|
||||
return indent(v:lnum) - l:shiftwidth
|
||||
endif
|
||||
return indent(l:prevlnum) + l:indent
|
||||
endfunction
|
||||
|
|
Loading…
Reference in a new issue