henrique vital
henrique vital

Reputation: 39

How do I set the vim plugin youCompleteMe to c++ and python?

I want to configure my vim file to set youcompleteme to autocomplete my cpp and .py files, but I don know how do this at the same time.

Upvotes: 1

Views: 4005

Answers (1)

Dmitry
Dmitry

Reputation: 446

~/.vimrc

let g:ycm_global_ycm_extra_conf = '~/.vim/bundle/YouCompleteMe/simple_ycm_extra_conf.py'
let g:ycm_seed_identifiers_with_syntax = 1
set completeopt=menu

" make YCM compatible with UltiSnips (using <Ctrl-N>, <Ctrl-P>)
let g:ycm_key_list_select_completion=[]
let g:ycm_key_list_previous_completion=[]

" commands mappings
nnoremap <F1> :pclose<CR>:silent YcmCompleter GetDoc<CR>
nnoremap <S-F1> :pclose<CR>
nnoremap <C-F1> :YcmCompleter GetType<CR>
nnoremap <F9> :YcmCompleter GoTo<CR>
nnoremap <S-F9> :YcmCompleter GoToReferences<CR>
nnoremap <F10> :YcmCompleter FixIt<CR>

let g:ycm_use_clangd = 1

~/.vim/bundle/YouCompleteMe/simple_ycm_extra_conf.py used as default YCM build rules for C++. For more complex projects I recommend use cmake as described in YCM manual. Also note that clangd YCM compilation allows you to use more commands.

def Settings( **kwargs ):
  return {
    'flags': [ '-x', 'c++', '-Wall', '-Wextra', '-Werror' ],
  }

Upvotes: 3

Related Questions