]> git.rmz.io Git - dotfiles.git/blobdiff - vim/ftplugin/cpp.vim
Makefile: add target for git
[dotfiles.git] / vim / ftplugin / cpp.vim
index 542503a79c2d015e3dd639259d61b23ed6277640..5154d621d11e6d1142877707325c2a414981ef7c 100644 (file)
@@ -14,16 +14,35 @@ setlocal cinoptions+=:0  " don't indent case labels
 " Load the doxygen syntax
 let b:load_doxygen_syntax = 1
 
-augroup fswitch
-    au BufEnter *.h   let b:fswitchdst  = 'cpp,c'
-    au BufEnter *.h   let b:fswitchlocs = 'reg:|include.*|source|'
-    au BufEnter *.cpp let b:fswitchdst  = 'h'
-    au BufEnter *.cpp let b:fswitchlocs = 'reg:|source|include/**|'
-augroup END
+let g:switch_custom_definitions =
+    \ [
+    \   ['EXPECT_FALSE', 'EXPECT_TRUE'],
+    \   ['EXPECT_EQ', 'EXPECT_NE'],
+    \   ['EXPECT_LT', 'EXPECT_GT'],
+    \   ['ASSERT_FALSE', 'ASSERT_TRUE'],
+    \   ['ASSERT_EQ', 'ASSERT_NE'],
+    \   ['ASSERT_LT', 'ASSERT_GT']
+    \ ]
+
+let g:switch_const_definitions =
+    \ [ {
+    \   '\%(const \)\@!\([[:alnum:]_:<>]\{-}\) \%(&\)\@!': 'const \1 ',
+    \   'const \([[:alnum:]_:<>]\{-}\) &\@!': 'const \1 &' ,
+    \   'const \([[:alnum:]_:<>]\{-}\) &': '\1 '
+    \ } ]
+
+nnoremap <buffer> <leader>c :call switch#Switch(g:switch_const_definitions, {})<cr>
 
 nnoremap <buffer> gd :YcmCompleter GoTo<CR>
 nnoremap <buffer> <C-W>d :vs<CR>:YcmCompleter GoTo<CR>
 
+" format with =
+map <buffer> = <Plug>(operator-clang-format)
+vnoremap <buffer> = :ClangFormat<CR>
+" restore = mapping to g=
+nnoremap <buffer>g= =
+vnoremap <buffer>g= =
+
 setlocal errorformat=
 setlocal errorformat+=%f:%l:%c:\ %trror:\ %m
 setlocal errorformat+=%f:%l:%c:\ %tarning:\ %m