I broke up with neovim....vim is my best friend now
This commit is contained in:
37
dot_vim/after/ftplugin/coffee/folding.vim
Normal file
37
dot_vim/after/ftplugin/coffee/folding.vim
Normal file
@@ -0,0 +1,37 @@
|
||||
function! CoffeeIndentLevel(lnum)
|
||||
return indent(a:lnum) / &shiftwidth
|
||||
endfunction
|
||||
|
||||
function! NextNonBlankLine(lnum)
|
||||
let numlines = line('$')
|
||||
let current = a:lnum + 1
|
||||
|
||||
while current <= numlines
|
||||
if getline(current) =~? '\v\S'
|
||||
return current
|
||||
endif
|
||||
|
||||
let current += 1
|
||||
endwhile
|
||||
|
||||
return -2
|
||||
endfunction
|
||||
|
||||
function! CoffeeFolds()
|
||||
if getline(v:lnum) =~ '\v^\s*$'
|
||||
return '-1'
|
||||
endif
|
||||
|
||||
let this_indent = IndentLevel(a:lnum)
|
||||
let next_indent = IndentLevel(NextNonBlankLine(a:lnum))
|
||||
|
||||
if next_indent == this_indent
|
||||
return this_indent
|
||||
elseif next_indent < this_indent
|
||||
return this_indent
|
||||
elseif next_indent > this_indent
|
||||
return '>' . next_indent
|
||||
endif
|
||||
endfunction
|
||||
setlocal foldmethod=expr
|
||||
setlocal foldexpr=CoffeeFolds()
|
||||
Reference in New Issue
Block a user