better foldtext()

This commit is contained in:
ManjaroOne666 2018-09-24 18:12:10 +01:00
parent 07639cdb88
commit fed62ab5ab
1 changed files with 12 additions and 4 deletions

View File

@ -94,11 +94,19 @@ function! MyFoldText()
let l:linecount = v:foldend - v:foldstart - 1 let l:linecount = v:foldend - v:foldstart - 1
let l:line = getline(v:foldstart) let l:line = getline(v:foldstart)
let l:prefix = '|+' . l:linecount . v:folddashes . '| ' let l:postfix = ' +' . l:linecount . ' ' . v:folddashes . '|'
let l:subexp = '^ \{,' . len(l:prefix) . '}' " unicode characters counted as 2 digits in length - TODO find fix
" let l:postfix = ' •••••••••••• +' . l:linecount . ' ' . v:folddashes . '|'
let l:foldtext = substitute(l:line, l:subexp, l:prefix, '') let l:len_line = len(l:line)
let l:foldtext = substitute(l:foldtext, '"{\{3}', '', '') let l:len_postfix = len(l:postfix)
if l:len_line + l:len_postfix <= 80
let l:padding = ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -'[0:79 - l:len_line - l:len_postfix]
let l:foldtext = l:line . l:padding . l:postfix
else
let l:foldtext = l:line[:76 - l:len_postfix] . '...' . l:postfix
endif
return l:foldtext return l:foldtext
endfunction endfunction