cd .vim/bundle/YouCompleteMe
./install.py --clang-completer
編譯完成
cp third_party/ycmd/examples/.ycm_extra_conf.py ~/.vim
在vimrc 添加
let g:ycm_server_python_interpreter='/usr/bin/python2.7'
let g:ycm_global_ycm_extra_conf='~/.vim/.ycm_extra_conf.py'
測試打開c文件,顯示
The ycmd server SHUT DOWN (restart with ':YcmRestartServer'). Unexpected exit code 1. Type ':YcmToggleLogs ycmd_41096_stderr_g94lju2q.log' to check the logs.
依照提示:YcmToggleLogs ycmd_41096_stderr_g94lju2q.log,發現文件是空。
使用另一種方法測試,參見https://github.com/ycm-core/YouCompleteMe/issues/2831
cd ~/.vim/bundle/YouCompleteMe/third/ycmd
cp ycmd/default_settings.json .
python ycmd --options_file default_settings.json
顯示:
Traceback (most recent call last):
File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
exec code in run_globals
File "/home/chh/.vim/bundle/YouCompleteMe/third_party/ycmd/ycmd/__main__.py", line 44, in <module>
from ycmd.hmac_plugin import HmacPlugin
File "/home/chh/.vim/bundle/YouCompleteMe/third_party/ycmd/ycmd/hmac_plugin.py", line 25, in <module>
import requests
ImportError: No module named requests
解決方法,安裝requests
sudo pipe install requests
可參考https://blog.csdn.net/weixin_33910460/article/details/93499001
再次測試
python ycmd --options_file default_settings.json
顯示
serving on http://localhost:45137
ok,完成。打開C文件也無YCM提示。