9 "TODO these are ignored because we set indentexpr in `indent/cpp.vim`
10 " Ideally, indentexpr should read the settings from .clang-format if it exists
11 setlocal nosmartindent
13 setlocal cinkeys-=0# " don't reindent PP directives
14 setlocal cinoptions+=:0 " don't indent case labels
16 " Load the doxygen syntax
17 let b:load_doxygen_syntax = 1
21 au BufEnter *.h let b:fswitchdst = 'cpp,cc,c'
22 au BufEnter *.h let b:fswitchlocs = '.,reg:|include.*|src|'
23 au BufEnter *.hpp let b:fswitchdst = 'cpp,c'
24 au BufEnter *.hpp let b:fswitchlocs = '.,reg:|include.*|src|'
25 au BufEnter *.cpp let b:fswitchdst = 'hpp,h'
26 au BufEnter *.cpp let b:fswitchlocs = '.,reg:|src|include/**|'
29 let g:switch_custom_definitions =
31 \ ['EXPECT_FALSE', 'EXPECT_TRUE'],
32 \ ['EXPECT_EQ', 'EXPECT_NE'],
33 \ ['EXPECT_LT', 'EXPECT_GT'],
34 \ ['ASSERT_FALSE', 'ASSERT_TRUE'],
35 \ ['ASSERT_EQ', 'ASSERT_NE'],
36 \ ['ASSERT_LT', 'ASSERT_GT']
39 let g:switch_const_definitions =
41 \ '\%(const \)\@!\([[:alnum:]_:<>]\{-}\) \%(&\)\@!': 'const \1 ',
42 \ 'const \([[:alnum:]_:<>]\{-}\) &\@!': 'const \1 &' ,
43 \ 'const \([[:alnum:]_:<>]\{-}\) &': '\1 '
46 nnoremap <buffer> <leader>c :call switch#Switch({'definitions': g:switch_const_definitions})<cr>
49 " TODO I don't remember these errorformat or what they match, maybe CMake? {{{
50 setlocal errorformat+=\ %##%n\ %m\ %f:%l:%c
51 setlocal errorformat+=\ %##%n\ %m\ %f
52 setlocal errorformat+=%n
54 setlocal errorformat+=%f:%l:%c:\ %trror:\ %m
55 setlocal errorformat+=%f:%l:%c:\ %tarning:\ %m
56 setlocal errorformat+=%D%*\\a[%*\\d]:\ Entering\ directory\ [`']%f'
57 setlocal errorformat+=%X%*\\a[%*\\d]:\ Leaving\ directory\ [`']%f'
58 setlocal errorformat+=%D%*\\a:\ Entering\ directory\ [`']%f'
59 setlocal errorformat+=%X%*\\a:\ Leaving\ directory\ [`']%f'
60 setlocal errorformat+=%*[^[]\[%tRROR\]%m\ \[%f:%l\]
61 setlocal errorformat+=%*[^[]\[%tARNING\]%m\ \[%f:%l\]
64 let g:termdebug_wide = 1
65 function! s:Debug(...)
68 au BufDelete !gdb ++once if exists('t:debug_tab') | tabclose | endif
70 "TODO restore mappings
71 "TODO make mappings local to source buffer
72 nnoremap <buffer> <C-T> :call TermDebugSendCommand('advance -source '.expand('%').' -line '.line("."))<CR>
73 nnoremap <buffer> <C-S> :Step<CR>
74 nnoremap <buffer> <C-N> :Over<CR>
75 nnoremap <buffer> <C-F> :Finish<CR>
77 command! -nargs=* -complete=file -bang Debug call <SID>Debug() | Termdebug<bang> <args>
78 command! -nargs=+ -complete=file -bang DebugCommand call <SID>Debug() | TermdebugCommand<bang> <args>
80 setlocal foldmethod=syntax
81 " set foldlevel according to number of matches of 'namespace' and 'class' not
83 function! InitialFoldLevel()
85 keepjumps keeppatterns silent! 1,/}/s/^\(namespace\|class\) \+[^;]*$//n
87 let &l:foldlevel=str2nr(split(v:statusmsg)[0])
90 call InitialFoldLevel()