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 = 'c,cpp'
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>
48 " Disable ale as we use ycm
51 nnoremap <buffer> gd :YcmCompleter GoTo<CR>
52 nnoremap <buffer> <C-W>d :vs<CR>:YcmCompleter GoTo<CR>
53 nnoremap <buffer> gD :YcmCompleter GoToReferences<CR>
55 nnoremap <buffer> <leader>fi :YcmCompleter FixIt<CR>
58 call operator#user#define_ex_command('ycmcompleter-format', 'YcmCompleter Format')
59 map <buffer> = <Plug>(operator-ycmcompleter-format)
60 vnoremap <buffer> = :YcmCompleter Format<CR>
61 " restore = mapping to g=
66 setlocal errorformat+=%f:%l:%c:\ %trror:\ %m
67 setlocal errorformat+=%f:%l:%c:\ %tarning:\ %m
68 setlocal errorformat+=%D%*\\a[%*\\d]:\ Entering\ directory\ [`']%f'
69 setlocal errorformat+=%X%*\\a[%*\\d]:\ Leaving\ directory\ [`']%f'
70 setlocal errorformat+=%D%*\\a:\ Entering\ directory\ [`']%f'
71 setlocal errorformat+=%X%*\\a:\ Leaving\ directory\ [`']%f'
72 setlocal errorformat+=%*[^[]\[%tRROR\]%m\ \[%f:%l\]
73 setlocal errorformat+=%*[^[]\[%tARNING\]%m\ \[%f:%l\]
76 let g:termdebug_wide = 1
77 function! s:Debug(...)
80 au BufDelete !gdb ++once if exists('t:debug_tab') | tabclose | endif
82 "TODO restore mappings
83 "TODO make mappings local to source buffer
84 nnoremap <buffer> <C-T> :call TermDebugSendCommand('advance -source '.expand('%').' -line '.line("."))<CR>
85 nnoremap <buffer> <C-S> :Step<CR>
86 nnoremap <buffer> <C-N> :Over<CR>
87 nnoremap <buffer> <C-F> :Finish<CR>
89 command! -nargs=* -complete=file -bang Debug call <SID>Debug() | Termdebug<bang> <args>
90 command! -nargs=+ -complete=file -bang DebugCommand call <SID>Debug() | TermdebugCommand<bang> <args>
92 setlocal foldmethod=syntax
93 " set foldlevel according to number of matches of 'namespace' and 'class' not
95 function! InitialFoldLevel()
97 keepjumps keeppatterns silent! 1,/}/s/^\(namespace\|class\) \+[^;]*$//n
99 let &l:foldlevel=str2nr(split(v:statusmsg)[0])
102 call InitialFoldLevel()