]> git.rmz.io Git - dotfiles.git/blobdiff - vim/ftplugin/cpp.vim
vim: packadd needs ! to avoid being loaded twice from vimrc
[dotfiles.git] / vim / ftplugin / cpp.vim
index ea6837f7200683f9ed688fbd1ddd67419c1000bb..d24f1ff44a570d2def86a18b419ee117f6f0e73b 100644 (file)
@@ -60,7 +60,7 @@ setlocal errorformat+=%X%*\\a:\ Leaving\ directory\ [`']%f'
 setlocal errorformat+=%*[^[]\[%tRROR\]%m\ \[%f:%l\]
 setlocal errorformat+=%*[^[]\[%tARNING\]%m\ \[%f:%l\]
 
-packadd termdebug
+packadd! termdebug
 let g:termdebug_wide = 1
 function! s:Debug(...)
     tabedit %
@@ -88,3 +88,18 @@ function! InitialFoldLevel()
     endif
 endf
 call InitialFoldLevel()
+
+function! MyCppFoldText()
+  let l:line = getline(v:foldstart)
+  " expand tabs in line, foldtext does not do it on its own
+  let l:line = substitute(l:line, "\t", repeat(" ", shiftwidth()), "g")
+  let l:width = min([&textwidth, winwidth(0)])
+  let l:lineinfo = printf("%d", v:foldend - v:foldstart)
+  let l:ellipsis = "…"
+  return printf("%.*s%s%*d",
+        \ l:width - strdisplaywidth(l:ellipsis..l:lineinfo), l:line,
+        \ l:ellipsis,
+        \ l:width - strdisplaywidth(l:line..l:ellipsis),     l:lineinfo)
+endfunction
+setlocal foldtext=MyCppFoldText()
+setlocal fillchars+=fold:\