- commit
- c05687f4e76eb1832c463bc4297530a9a393b42e
- parent
- 4fea2b3caf4701dd81e17b7d7c0b71526fd3bc44
- Author
- Tobias Bengfort <tobias.bengfort@posteo.de>
- Date
- 2019-02-23 18:04
use autoload
Diffstat
| R | after/plugin/folding.vim -> autoload/folding.vim | 17 | ++++++----------- |
| A | plugin/folding.vim | 4 | ++++ |
2 files changed, 10 insertions, 11 deletions
diff --git a/after/plugin/folding.vim b/autoload/folding.vim
@@ -1,8 +1,8 @@1 -1 function! IndentLevel(lnum)-1 1 function! s:IndentLevel(lnum) 2 2 return indent(a:lnum) / &shiftwidth 3 3 endfunction 4 45 -1 function! NextNonBlankLine(lnum)-1 5 function! s:NextNonBlankLine(lnum) 6 6 let numlines = line('$') 7 7 let current = a:lnum + 1 8 8 @@ -18,13 +18,13 @@ function! NextNonBlankLine(lnum) 18 18 endfunction 19 19 20 20 " fold by indent, but include first line21 -1 function! IndentFold(lnum)-1 21 function! folding#IndentFold(lnum) 22 22 if getline(a:lnum) =~? '\v^\s*$' 23 23 return '-1' 24 24 endif 25 2526 -1 let this_indent = IndentLevel(a:lnum)27 -1 let next_indent = IndentLevel(NextNonBlankLine(a:lnum))-1 26 let this_indent = s:IndentLevel(a:lnum) -1 27 let next_indent = s:IndentLevel(s:NextNonBlankLine(a:lnum)) 28 28 29 29 if next_indent <= this_indent 30 30 return this_indent @@ -34,7 +34,7 @@ function! IndentFold(lnum) 34 34 endfunction 35 35 36 36 " display first line with correct indentation37 -1 function! IndentFoldText()-1 37 function! folding#IndentFoldText() 38 38 let firstline = getline(v:foldstart) 39 39 if &expandtab 40 40 let space = '' @@ -43,8 +43,3 @@ function! IndentFoldText() 43 43 endif 44 44 return space . firstline 45 45 endfunction46 -147 -1 set foldlevel=9948 -1 set foldmethod=expr49 -1 set foldexpr=IndentFold(v:lnum)50 -1 set foldtext=IndentFoldText()
diff --git a/plugin/folding.vim b/plugin/folding.vim
@@ -0,0 +1,4 @@ -1 1 set foldlevel=99 -1 2 set foldmethod=expr -1 3 set foldexpr=folding#IndentFold(v:lnum) -1 4 set foldtext=folding#IndentFoldText()