]> git.rmz.io Git - dotfiles.git/blob - vim/ftplugin/c.vim
zsh: don't do task-quote-magic on global aliases
[dotfiles.git] / vim / ftplugin / c.vim
1 " Load the doxygen syntax
2 let b:load_doxygen_syntax = 1
3
4 augroup fswitch
5 au!
6 au BufEnter *.h let b:fswitchdst = 'c,cpp,cxx'
7 au BufEnter *.h let b:fswitchlocs = '.,reg:|include.*|src|'
8 au BufEnter *.c let b:fswitchdst = 'h'
9 au BufEnter *.c let b:fswitchlocs = 'reg:|source|include/**|'
10 augroup END
11
12 if exists("g:loaded_youcompleteme")
13 " Disable ale as we use ycm
14 let b:ale_enabled = 0
15
16 nnoremap <buffer> gd :YcmCompleter GoTo<CR>
17 nnoremap <buffer> <C-W>d :vs<CR>:YcmCompleter GoTo<CR>
18 nnoremap <buffer> gD :YcmCompleter GoToReferences<CR>
19
20 " replaced with <leader>ca (code action) in neovim
21 nnoremap <buffer> <leader>fi :YcmCompleter FixIt<CR>
22 " replaced with <leader>cr (code rename) in neovim
23 nnoremap <buffer> <leader>fr :YcmCompleter RefactorRename<space>
24
25 " format with =
26 call operator#user#define_ex_command('ycmcompleter-format', 'YcmCompleter Format')
27 map <buffer> = <Plug>(operator-ycmcompleter-format)
28 vnoremap <buffer> = :YcmCompleter Format<CR>
29 " restore = mapping to g=
30 nnoremap <buffer>g= =
31 vnoremap <buffer>g= =
32
33 " hover popup
34 let g:ycm_auto_hover = ''
35 let b:ycm_hover = { 'command': 'GetDoc', 'syntax': &filetype }
36 nmap <buffer> gh <plug>(YCMHover)
37 nmap <buffer> gH :YcmCompleter GetDoc<CR>
38 else
39 " I'm way to used to using = to format than to switch to gq
40 nnoremap <buffer> = gq
41 nnoremap <buffer> == gqq
42 vnoremap <buffer> = gq
43 endif
44
45 let b:tcomment_options = {'whitespace': 'no'}
46
47 setlocal cinoptions+=l1 " align with case label