YouCompleteMe自动补全C语言大型项目
我的ycm在vimrc中的配置" YouCompleteMe相关配置
let g:ycm_server_python_interpreter='/usr/bin/python'
let g:ycm_global_ycm_extra_conf='~/.vim/.ycm_extra_conf.py'
let g:ycm_show_diagnostics_ui = 0 "关闭语法提示
let g:ycm_complete_in_comments=1 " 补全功能在注释中同样有效
let g:ycm_confirm_extra_conf=0 " 允许 vim 加载 .ycm_extra_conf.py 文件,不再提示
let g:ycm_collect_identifiers_from_tags_files=1 " 开启 YCM 标签补全引擎
let g:ycm_min_num_of_chars_for_completion=1 " 从第一个键入字符就开始罗列匹配项
let g:ycm_cache_omnifunc=0 " 禁止缓存匹配项,每次都重新生成匹配项
let g:ycm_seed_identifiers_with_syntax=1 " 语法关键字补全
let g:ycm_goto_buffer_command = 'horizontal-split' " 跳转打开上下分屏
map :YcmCompleter GoToDefinition
map :YcmCompleter GoToDeclaration
map :YcmCompleter GoToDefinitionElseDeclaration
ycm的配置文件,就放在项目源码目录内
系统头文件路径
第三方共享库的头文件路径
项目自己的头文件路径vim .ycm_extra_conf.py
修改flags
flags = [
'-std=gunc99',
'-x',
'c',
'-isystem',
'/usr/include/',
'-isystem',
'/home/chunli/work/01_第三方共享库头文件路径/',
'-isystem',
'/home/chunli/work/01_chunli/08_本项目头文件路径/',
]
ycm_extra_conf.py 路径中不要有中文, 否则打开vim出现以下报错ycm_extra_conf.py 路径中不要有中文, 否则打开vim出现以下报错
UnicodeEncodeError: 'ascii' codec can't encode characters in position 37-40: ordinal not in range(128)
解决办法
1,
在.ycm_extra_conf.py文件首行添加
# encoding=utf8
2,创建文件,写入信息
chunli@CentOS~$ sudo find / -name 'site-packages'
/usr/share/xemacs/site-packages
/usr/lib/python2.6/site-packages
chunli@CentOS~$ sudo vim /usr/lib/python2.6/site-packages/sitecustomize.py
import sys
sys.setdefaultencoding('utf-8')
chunli@CentOS~$
ycm 排错#需要在vimrc 开启let g:ycm_show_diagnostics_ui = 0 "关闭语法提示
ycm其他命令
:messages
:YcmDiags
:YcmDebugInf