1
0
mirror of https://github.com/jdhao/nvim-config.git synced 2025-06-08 14:14:33 +02:00

update foldtext function

This commit is contained in:
jdhao 2020-09-30 16:23:38 +08:00
parent 2b015bd51e
commit 191abbcf88

View File

@ -68,11 +68,11 @@ endfunction
" Custom fold text, adapted from https://vi.stackexchange.com/a/3818/15292
" and https://vi.stackexchange.com/a/6608/15292
function! utils#MyFoldText() abort
let line = getline(v:foldstart)
let folded_line_num = v:foldend - v:foldstart
let line_text = substitute(line, '^"{\+', '', 'g')
let fillcharcount = &textwidth - len(line_text) - len(folded_line_num) - 10
return printf('+%s%s%s (%s L)', repeat('-', 4), line_text, repeat('.', fillcharcount), folded_line_num)
let l:line = getline(v:foldstart)
let l:fold_line_num = v:foldend - v:foldstart
let l:fold_text = substitute(l:line, '^"{\+', '', 'g')
let l:fill_char_num = &textwidth - len(l:fold_text) - len(l:fold_line_num) - 10
return printf('+%s%s%s (%s L)', repeat('-', 4), l:fold_text, repeat('.', l:fill_char_num), l:fold_line_num)
endfunction
" Toggle cursor column