X-Git-Url: https://git.rmz.io/dotfiles.git/blobdiff_plain/dc229eb1026cd32640f8bd4aff9583779d6e39a1..b47ffe60e244c9165f40371736079320ea2d848b:/vim/ftplugin/cpp.vim diff --git a/vim/ftplugin/cpp.vim b/vim/ftplugin/cpp.vim index b54cffd..19850a7 100644 --- a/vim/ftplugin/cpp.vim +++ b/vim/ftplugin/cpp.vim @@ -18,7 +18,7 @@ let b:load_doxygen_syntax = 1 augroup fswitch_cpp au! - au BufEnter *.h let b:fswitchdst = 'c,cpp' + au BufEnter *.h let b:fswitchdst = 'cpp,cc,c' au BufEnter *.h let b:fswitchlocs = '.,reg:|include.*|src|' au BufEnter *.hpp let b:fswitchdst = 'cpp,c' au BufEnter *.hpp let b:fswitchlocs = '.,reg:|include.*|src|' @@ -43,21 +43,14 @@ let g:switch_const_definitions = \ 'const \([[:alnum:]_:<>]\{-}\) &': '\1 ' \ } ] -nnoremap c :call switch#Switch(g:switch_const_definitions, {}) - -nnoremap gd :YcmCompleter GoTo -nnoremap d :vs:YcmCompleter GoTo -nnoremap gD :YcmCompleter GoToReferences - -" format with = -call operator#user#define_ex_command('ycmcompleter-format', 'YcmCompleter Format') -map = (operator-ycmcompleter-format) -vnoremap = :YcmCompleter Format -" restore = mapping to g= -nnoremap g= = -vnoremap g= = +nnoremap c :call switch#Switch({'definitions': g:switch_const_definitions}) setlocal errorformat= +" TODO I don't remember these errorformat or what they match, maybe CMake? {{{ +setlocal errorformat+=\ %##%n\ %m\ %f:%l:%c +setlocal errorformat+=\ %##%n\ %m\ %f +setlocal errorformat+=%n +"}}} setlocal errorformat+=%f:%l:%c:\ %trror:\ %m setlocal errorformat+=%f:%l:%c:\ %tarning:\ %m setlocal errorformat+=%D%*\\a[%*\\d]:\ Entering\ directory\ [`']%f' @@ -95,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:\