离开youcompleteme, vim的使用体验差很多。
下面是vimrc文件中ycm相关配置demo。对于C/C++语言的语法补齐需要安装clangd.
set nu
set expandtab
set tabstop=4
set shiftwidth=4
set mouse=a
set shell=bash
set hls
set encoding=utf-8
"YoucomPleteMe:语句补全插件", ref to https://blog.csdn.net/OIDCAT/article/details/106816941
set runtimepath+=~/.vim/bundle/YouCompleteMe
set shellcmdflag=-ic
autocmd InsertLeave * if pumvisible() == 0|pclose|endif " 离开插入模式后自动关闭预览窗口"
let g:ycm_clangd_uses_ycmd_caching = 0
let g:ycm_collect_identifiers_from_tags_files = 1 " 开启YCM基于标签引擎
let g:ycm_collect_identifiers_from_comments_and_strings = 1 " 注释与字符串中的内容也用于补全
let g:syntastic_ignore_files=[".*\.py$"]
let g:ycm_seed_identifiers_with_syntax = 1 " 语法关键字补全
let g:ycm_complete_in_strings = 1
let g:ycm_confirm_extra_conf = 0 " 关闭加载.ycm_extra_conf.py提示
let g:ycm_key_list_select_completion = ['<c-n>', '<Down>'] " 映射按键,没有这个会拦截掉tab, 导致其他插件的tab不能用.
let g:ycm_key_list_previous_completion = ['<c-p>', '<Up>']
let g:ycm_key_invoke_completion = '<C-a>'
let g:ycm_complete_in_comments = 1 " 在注释输入中也能补全
let g:ycm_complete_in_strings = 1 " 在字符串输入中也能补全
let g:ycm_collect_identifiers_from_comments_and_strings = 1 " 注释和字符串中的文字也会被收入补全
let g:ycm_global_ycm_extra_conf='~/.vim/bundle/YouCompleteMe/third_party/ycmd/.ycm_extra_conf.py'
"let g:ycm_global_ycm_extra_conf='~/.vim/.ycm_extra_conf.py' "加载文件路径
let g:ycm_clangd_binary_path = "~/software/llvm-13.0.0.obj/bin/clangd"
"let g:clang_library_path='/home/zwl/software/llvm-13.0.0.obj/lib/libclang.so' "libclang路径
let g:ycm_show_diagnostics_ui = 0 " 禁用语法检查
inoremap <expr> <CR> pumvisible() ? "<Down>\<CR>" : "\<CR>"
inoremap <a-cr> <CR>
nnoremap <c-j> :YcmCompleter GoToDefinitionElseDeclaration<CR>
let g:ycm_min_num_of_chars_for_completion = 2 " 从第2个键入字符就开始罗列匹配项
let g:ycm_max_num_candidates = 15 " 候选数量设置
let g:ycm_auto_trigger = 1 " 签名帮助
标签:set,补全,配置文件,extra,conf,demo,youcomplete,let,ycm
From: https://www.cnblogs.com/zwlwf/p/18248743