vim-indent-folding

indentation based folding for vim
git clone https://git.ce9e.org/vim-indent-folding.git

commit
c6fedf54831c29c40130ff82f68cfc5f4cda6ce0
parent
c05687f4e76eb1832c463bc4297530a9a393b42e
Author
Tobias Bengfort <tobias.bengfort@posteo.de>
Date
2019-02-23 18:06
use explicit local variables

Diffstat

M autoload/folding.vim 28 ++++++++++++++--------------

1 files changed, 14 insertions, 14 deletions


diff --git a/autoload/folding.vim b/autoload/folding.vim

@@ -3,15 +3,15 @@ function! s:IndentLevel(lnum)
    3     3 endfunction
    4     4 
    5     5 function! s:NextNonBlankLine(lnum)
    6    -1 	let numlines = line('$')
    7    -1 	let current = a:lnum + 1
   -1     6 	let l:numlines = line('$')
   -1     7 	let l:current = a:lnum + 1
    8     8 
    9    -1 	while current <= numlines
   -1     9 	while l:current <= l:numlines
   10    10 		if getline(current) =~? '\v\S'
   11    -1 			return current
   -1    11 			return l:current
   12    12 		endif
   13    13 
   14    -1 		let current += 1
   -1    14 		let l:current += 1
   15    15 	endwhile
   16    16 
   17    17 	return -1
@@ -23,23 +23,23 @@ function! folding#IndentFold(lnum)
   23    23 		return '-1'
   24    24 	endif
   25    25 
   26    -1 	let this_indent = s:IndentLevel(a:lnum)
   27    -1 	let next_indent = s:IndentLevel(s:NextNonBlankLine(a:lnum))
   -1    26 	let l:this_indent = s:IndentLevel(a:lnum)
   -1    27 	let l:next_indent = s:IndentLevel(s:NextNonBlankLine(a:lnum))
   28    28 
   29    -1 	if next_indent <= this_indent
   30    -1 		return this_indent
   -1    29 	if l:next_indent <= l:this_indent
   -1    30 		return l:this_indent
   31    31 	else
   32    -1 		return '>' . next_indent
   -1    32 		return '>' . l:next_indent
   33    33 	endif
   34    34 endfunction
   35    35 
   36    36 " display first line with correct indentation
   37    37 function! folding#IndentFoldText()
   38    -1 	let firstline = getline(v:foldstart)
   -1    38 	let l:firstline = getline(v:foldstart)
   39    39 	if &expandtab
   40    -1 		let space = ''
   -1    40 		let l:space = ''
   41    41 	else
   42    -1 		let space = repeat(' ', indent(v:foldstart) - indent(v:foldstart) / &tabstop)
   -1    42 		let l:space = repeat(' ', indent(v:foldstart) - indent(v:foldstart) / &tabstop)
   43    43 	endif
   44    -1 	return space . firstline
   -1    44 	return l:space . l:firstline
   45    45 endfunction