From fed62ab5ab73741048941e4577f1e2b3f741e75c Mon Sep 17 00:00:00 2001 From: ManjaroOne666 Date: Mon, 24 Sep 2018 18:12:10 +0100 Subject: [PATCH] better foldtext() --- vimrc.functions.vim | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/vimrc.functions.vim b/vimrc.functions.vim index daedd9d..e82975d 100644 --- a/vimrc.functions.vim +++ b/vimrc.functions.vim @@ -94,11 +94,19 @@ function! MyFoldText() let l:linecount = v:foldend - v:foldstart - 1 let l:line = getline(v:foldstart) - let l:prefix = '|+' . l:linecount . v:folddashes . '| ' - let l:subexp = '^ \{,' . len(l:prefix) . '}' + let l:postfix = ' +' . l:linecount . ' ' . v:folddashes . '|' + " 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:foldtext = substitute(l:foldtext, '"{\{3}', '', '') + let l:len_line = len(l:line) + 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 endfunction