mirror of
https://github.com/dag/vim-fish
synced 2024-09-16 13:44:02 +02:00
move indentexpr function to autoload
This commit is contained in:
parent
ccebc890ba
commit
11fcbbeeca
2 changed files with 24 additions and 33 deletions
|
@ -1,3 +1,26 @@
|
|||
function! fish#Indent()
|
||||
let l:lnum = prevnonblank(v:lnum - 1)
|
||||
if l:lnum ==# 0
|
||||
return 0
|
||||
endif
|
||||
let l:ind = 0
|
||||
if getline(l:lnum) =~# '\v^\s*switch>'
|
||||
let l:ind = &shiftwidth * 2
|
||||
elseif getline(l:lnum) =~# '\v^\s*%(begin|if|else|while|for|function|case)>'
|
||||
let l:ind = &shiftwidth
|
||||
endif
|
||||
if getline(v:lnum) =~# '\v^\s*end>'
|
||||
if l:ind ==# 0
|
||||
return indent(v:lnum) - &shiftwidth
|
||||
else
|
||||
return indent(v:lnum) - l:ind
|
||||
endif
|
||||
elseif getline(v:lnum) =~# '\v^\s*%(case|else)>'
|
||||
return indent(v:lnum) - &shiftwidth
|
||||
endif
|
||||
return indent(l:lnum) + l:ind
|
||||
endfunction
|
||||
|
||||
function! fish#Complete(findstart, base)
|
||||
if a:findstart
|
||||
if getline('.') =~# '\v^\s*$'
|
||||
|
|
|
@ -1,34 +1,2 @@
|
|||
setlocal indentexpr=GetFishIndent()
|
||||
setlocal indentexpr=fish#Indent()
|
||||
setlocal indentkeys+==end,=else,=case
|
||||
|
||||
if exists('*GetFishIndent')
|
||||
finish
|
||||
endif
|
||||
|
||||
function GetFishIndent()
|
||||
let l:lnum = prevnonblank(v:lnum - 1)
|
||||
|
||||
if l:lnum ==# 0
|
||||
return 0
|
||||
endif
|
||||
|
||||
let l:ind = 0
|
||||
|
||||
if getline(l:lnum) =~# '\v^\s*switch>'
|
||||
let l:ind = &shiftwidth * 2
|
||||
elseif getline(l:lnum) =~# '\v^\s*%(begin|if|else|while|for|function|case)>'
|
||||
let l:ind = &shiftwidth
|
||||
endif
|
||||
|
||||
if getline(v:lnum) =~# '\v^\s*end>'
|
||||
if l:ind ==# 0
|
||||
return indent(v:lnum) - &shiftwidth
|
||||
else
|
||||
return indent(v:lnum) - l:ind
|
||||
endif
|
||||
elseif getline(v:lnum) =~# '\v^\s*%(case|else)>'
|
||||
return indent(v:lnum) - &shiftwidth
|
||||
endif
|
||||
|
||||
return indent(l:lnum) + l:ind
|
||||
endfunction
|
||||
|
|
Loading…
Reference in a new issue