git: Vim files
This commit is contained in:
parent
26e38ad5a1
commit
dfbed32287
19
contrib/vim/autoload/ft/cpphpp.vim
Normal file
19
contrib/vim/autoload/ft/cpphpp.vim
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
"
|
||||||
|
" Get the filename of the swap file
|
||||||
|
"
|
||||||
|
func! ft#cpphpp#GetFilename()
|
||||||
|
let ext = expand('%:e')
|
||||||
|
let root = expand('%:p:r')
|
||||||
|
if (ext == 'cpp')
|
||||||
|
return fnameescape(substitute(root, '\(src/.*/\)\?src/', '\1include/', '') . '.hpp')
|
||||||
|
elseif (ext == 'hpp')
|
||||||
|
return fnameescape(substitute(root, '\(include/.*/\)\?include/', '\1src/', '') . '.cpp')
|
||||||
|
endif
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
"
|
||||||
|
" Swap between source/header using given cmd
|
||||||
|
"
|
||||||
|
func! ft#cpphpp#Swap(cmd)
|
||||||
|
execute a:cmd . ' ' . ft#cpphpp#GetFilename()
|
||||||
|
endfunc
|
8
contrib/vim/ftplugin/cpp.vim
Normal file
8
contrib/vim/ftplugin/cpp.vim
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
" Swap between source/header
|
||||||
|
nnoremap <silent> <leader>af :call ft#cpphpp#Swap('edit')<cr>
|
||||||
|
nnoremap <silent> <leader>as :call ft#cpphpp#Swap('new')<cr>
|
||||||
|
nnoremap <silent> <leader>av :call ft#cpphpp#Swap('vnew')<cr>
|
||||||
|
|
||||||
|
" Code formatting using clang-format
|
||||||
|
set formatprg=/usr/bin/clang-format
|
||||||
|
nmap <f1> :ClangFormat<cr>
|
Loading…
Reference in New Issue
Block a user