-1

How to make the foldtext be applied globally on every file?. Nothing I've tried seem to work. I can make it work if I run :set foldtext=NeatFoldText() but I don't want to that on every file. This must be simple but I just don't know how. And yes I've got set foldtext=NeatFoldText() in my init.vim. Also can you exclude the character used for comments in the string?.

The folds look like this:

  1 ·  dein                                                                                                                                                     67 lines
68 ·  plugins                                                                                                                                               58 lines

Function:

function! NeatFoldText()
    let line = ' ' . substitute(getline(v:foldstart), '^\s*"\?\s*\|\s*"\?\s*{{' . '{\d*\s*', '', 'g') . ' '
    let lines_count = v:foldend - v:foldstart + 1
    let lines_count_text = printf("%10s", lines_count . ' lines')
    let foldchar = matchstr(&fillchars, 'fold:\zs.')
    let foldtextstart = strpart('·' . repeat(foldchar, v:foldlevel*1) . line, 0, (winwidth(0)*2)/3)
    let foldtextend = lines_count_text . repeat(foldchar, 6)
    let foldtextlength = strlen(substitute(foldtextstart . foldtextend, '.', 'x', 'g')) + &foldcolumn
    return foldtextstart . repeat(foldchar, winwidth(0)-foldtextlength) . foldtextend
endfunction

set foldtext=NeatFoldText()
Ingo Karkat
  • 167,457
  • 16
  • 250
  • 324

1 Answers1

0

The answer was rm -rf .local/share/nvim/view/ I found out using :verbose set foldtext? which yielded: Last set from ~/.local/share/nvim/view/~=+.config=+nvim=+init.vim= Thank you.