YCM install - win - vim
为什么不用cywin,msys2?
因为windows下,编译会自动选择m$的vs编译器,可能导致编译的时候用的是windows上的python,运行的时候用的cywin或msys2的python。
最终就是运行不了。
节约时间。就不折腾了。
基本
- win10 64位
- python3 64位
- vim 64位
- vs 2019
- git
- llvm
- cmake
可选
- openjdk 15
- node, npm
确保path
中只有一个python
下载
安装路径严禁空格,尽量不要自找麻烦。
llvm下载
https://releases.llvm.org/download.html
vim下载
https://github.com/vim/vim-win32-installer/releases
- 查看vim是否为
64
位版本,不支持python2,只支持python3/dyn
vim
:version
看输出是否包含:
-python
+python3/dyn
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -I/usr/include/ncursesw -march=x86-64
下载 vim-plug,以及ycm
https://github.com/junegunn/vim-plug
只需要一个文件plug.vim
放到
~/vimfiles/autoload/plug.vim
中国网络,下载github困难
文本编辑器打开plug.vim
let fmt = get(g:, 'plug_url_format', 'https://git::@github.com/%s.git')
替换为:
let fmt = get(g:, 'plug_url_format', 'https://git::@hub.fastgit.org/%s.git')
\ '^https://git::@github\.com', 'https://github.com', '')
替换为:
\ '^https://git::@hub.fastgit\.org', 'https://hub.fastgit.org', '')
会下载很多插件,依赖。
失败了就要相办法处理。
cd ~/vimfiles/plugged/YouCompleteMe
git submodule update --init --recursive
或者修改hosts文件
https://www.cnblogs.com/veezeng/p/15043111.html
安装插件
打开vim
:PlugInstall
cd ~/vimfiles/plugged/YouCompleteMe
python ./install.py --clang-completer --ts-completer --java-completer
debug
YouCompleteMe/third_party/ycmd/build.py
YouCompleteMe/third_party/ycmd/cpp/CMakeLists.txt
- 命令有输出
:YcmDebugInfo
- 应该加载2个
:filter you scriptnames
YouCompleteMe/plugin/youcompleteme.vim
YouCompleteMe/autoload/youcompleteme.vim
https://github.com/ycm-core/YouCompleteMe/wiki/FAQ
https://github.com/ycm-core/YouCompleteMe/wiki/Troubleshooting-steps-for-ycmd-server-SHUT-DOWN
more
The ycmd server SHUT DOWN (restart with :YcmRestartServer).
Unexpected exit code 1. Type ':YcmToggleLogs ycmd_57346_stderr_2hrqlh43.log' to check the logs.
Usually, after you check the log file it points to, you find it's empty. Sometimes the exit code is different,
but basically you followed the install guide correctly, but something isn't working.
You might have googled the error and found responses from many years ago that are all not relevant. Ignore them!
Check that ycmd can start manually
The best way to validate installation is to try and start ycmd manually using the process that YouCompleteMe will use.
Do this:
$ cd /path/to/YouCompleteMe/third_party/ycmd/
$ cat PYTHON_USED_DURING_BUILDING
/some/path/to/python3
$ cp ycmd/default_settings.json .
$ /some/path/to/python3 ycmd --options_file=default_settings.json
serving on http://localhost:<some port>
Check YCM installation
Finally, in vim, check :filter youcompleteme scriptnames
. Ensure that you only see entries for the correct locations:
/path/to/YCM/plugin/youcompleteme.vim
/path/to/YCM/autoload/youcompleteme.vim
Try with the minimal vimrc
Instructions in CONTRIBUTING.md
In short, test with
vim -Nu /path/to/YCM/vimrc_ycm_minimal
Try with one of the minimal test projects
There are example projects that are used by our test cases in
/path/to/YCM/third_party/ycmd/ycmd/tests/<language>/testdata.
Try to see if you get reasonable results when loading one of the test files in there,
and using the minimal vimrc. This rules out your project and your vim config.