Youcompleteme is a fast, As-you-type, Fuzzy-search code completion engine for Vim.
Reference: https://github.com/Valloric/YouCompleteMe#full-installation-guide
The default reader of this article knows what is Unix/linux,vim/vi, youcompleteme, if there is unclear, Search engine is your friend
or message discussion. Youcompleteme abbreviation YCM below are called YCM.
Youcompleteme 's strong presumably everyone has heard, simple in a word to summarize the words, 媲美 VS 的自动补全
of course, there may be a little bit too, but visible its strong. But as a very powerful vim plugin, he is very difficult to install, almost all people will struggle in the installation phase (do not ask how the old man knows), and then either successfully install the benefits of the tool to facilitate, or abandon the continued use of traditional auto-completion tools (of course, not so bad, but probably not YCM so powerful).
After the old man's hard exploration, finally heard the YCM name of a year after the successful installation, so share out, hope to help more people. Also if you encounter any problems during the installation process are welcome to discuss with me in the comments.
With you I am me, your existence makes me complete
--The Ladyship
System environment: Kali-rolling on Oracle VirtualBox, can be regarded as the latest version (or experimental version) of Debian
Objective: To successfully install and use YCM to compile software as little as possible (that is, to use precompiled Deb package as much as possible) and to achieve automatic completion in more languages.
Installation steps: 0. Make sure the VIM version is 7.4.143 or above and supports the Python 2/3 script
Vim version
It can be seen that the VIM version is 8.0.49 and supports Python3 scripts but does not support Python2 scripts (7th, 8 lines)
If you do not have the relevant Python script information in your print results, you can also type the command in Vim, which is :echo has(‘python‘) || has(‘python3‘)
supported if the result is 1.
If the VIM version does not meet the criteria or does not support the Python script, then you need to compile and install Vim from the source code ,
1. Install YCM via Vundle (official recommendation)
Quick install VIM plug-in management plugin Vundle
~/.vimrc
Add a line ( call vundle#begin()
call vundle#end()
between and) in the Vim configuration file
call vundle#begin(). . . Plugin ‘Valloric/YouCompleteMe’. . .call vundle#end()
Then save to run the vim command :PluginInstall
installation It is important to note that the time may be quite long .
The time to open vim may be a warning
Vim warning1.5 is installed via Git YCM
If you and the same, waiting for vundle installation YCM wait for a long time finally seems to be successful, open vim but found YouCompleteme unavailable : no module named future
(of course, did not meet you lucky), then you should consider swapping Git to install the YCM:
# 下载 (在 `~/.vim/bundle` 目录下)$ git clone --recursive [https://github.com/Valloric/YouCompleteMe.git](https://github.com/Valloric/YouCompleteMe.git)# 检查完整性(在 `~/.vim/bundle/YouCompleteMe` 目录下)$ git submodule update --init --recursive
2. Download and install the latest version of Libclang
Skip this step if you don't need semantic completion of the C-family
# apt-get install llvm-3.9 clang-3.9 libclang-3.9-dev libboost-all-dev
PS: YCM official wall recommend using upstream compiled binaries instead of the system's own Libclang
You can use the system Libclang only If sure it is version 3.9 or higher, otherwise don ' t. Even if it is, we recommend using the official binaries from llvm.org if at all possible. Make sure your download the correct archive file for your OS.
We strongly recommend against use of the system Libclang instead of the upstream compiled. Random things may break. Save yourself the hassle and use the upstream pre-built Libclang.
3. Compiling the Build
ycm_core
Library
Required: CMake Python3-dev
YCM's top-level directory or root directory should be ~/.vim/bundle/YouCompleteMe
- Create a directory to put files generated during compilation
cd ~/.ycm_build
If you skip the third step, you can run it directly
"Unix Makefiles" . ~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp
If you do not skip the third step, you need to run the semantic completion of the C-family
"Unix Makefiles" -DUSE_SYSTEM_BOOST=ON DUSE_SYSTEM_LIBCLANG=ON . ~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp
Problematic compilation
Compiled through, no error, but this compilation result is problematic, see the 3rd line, the repeated emphasis of the C-family of the semantic complement is not. After the old couple repeatedly check, it turns out that the above compilation command is a -
symbol of the missing
"Unix Makefiles" -DUSE_SYSTEM_BOOST=ON -DUSE_SYSTEM_LIBCLANG=ON . ~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp
The process of compiling this time is as follows:
Compile normal
In fact, this is still problematic, see the bottom 3rd, 4 lines, using the external libclang-3.6, the 2nd step of the system installed Libclang minimum if it is 3.9.
At this point you need to delete ~/.ycm_build
all the files in the directory and use the following command to specify the Libclang version to recompile.
"Unix Makefiles" -DUSE_SYSTEM_BOOST=ON -DEXTERNAL_LIBCLANG_PATH=/usr/lib/x86_64-linux-gnu/libclang-3.9.so . ~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp
The result of the compilation is the previously created directory (that is, some Makefile files are generated in the current directory)
Makefile
# --config Release 这个构建选项进针对 Windows$ cmake --build . --target ycm_core --config Release
Build ycm_core3.5 Configuration
- Copy the. ycm_extra_conf.py file
$ cp ~/.vim/bundle/YouCompleteMe/third_party/ycmd/examples/.ycm_extra_conf.py ~/.vim/
- Add VIM Configuration
Note the path to the following Python interpreter is the same version as the Python interpreter used when compiling Ycm_core (2 or 3)
“ ~/.vimrclet g:ycm_server_python_interpreter=‘/usr/bin/python‘let g:ycm_global_ycm_extra_conf=‘~/.vim/.ycm_extra_conf.py‘
4. Support in other languages
C #, Go, TypeScript, JavaScript, Rust support
As the couple do not have much to do with these languages do not introduce.
5. Test the installation
First create a new hello.c file,
hello.c
Can see the automatic completion of the header file, the YCM
Then run the command in vim to :YcmToggleLogs stderr
View the error log,
StdErr
Failure to see the error message proves that the YCM has been successfully installed.
Helperhaps-Aurora
Original: A stunning drop-down terminal Tilda & Guake
News column: Aurora Daily
Step by step you install the most difficult to install Vim plugin in history--youcompleteme