I always want imporve my skills on VIM. Thus recently I spent two days on setting up a VIM IDE for C/C++ proprogramming. Below are some useful steps for YCM.
SpecificationsMac Info
OS X Yosemite
Version 10.10.5
VIM
Mac OS Unix Version (MacVIM)
Vi Improved 8.0
And I also have installed HomeBrew for Mac and Vundle for Vim plugins management.
Latest MacVimFirst make sure you have HomeBrew in your computer, because it is a great tool to install some missing packages and tools in Mac OS.
You always want to install the lates MacVim, which is required by Youcompleteme. In your terminal, run:
brew update brew install vim && brew instal macvim brew link macvim
You should now be able to launch MacVIM from the terminal using mvim.
Reference
Install YCM using VundleThe following steps are according to the instruction in Github.
Note: I saw in the installation section that you can install it in a ideal way or following the full guidance. I tried the ideal way, but reality turned out never to be ideal. SO please follow the full guidance. It will help you understand what is going on inside YCM.
To use Vundle for installation, put the following line in your .vimrc configuration file:
Plugin "valloric/youcompleteme"
And then run PluginInstall in your VIM commandline. It should work just fine.
Install CMake using BrewCMake is a helpful tool to compile the source file, and is also suggested in the full guidance. A easy way to install it is using HomeBrew. Run these:
brew install cmake
Reference
Just for synchronization, if you type in the terminal cmake, you should get the usage info for the function.
Download and extract libclang for C/C++ semantic completionThis is an important step to make sure that your YCM will be powered to do semantic completion for the specific languages.
Here comes HomeBrew again. Run brew install llvm will download and extract the libclang for you. Wait a minute when the process is done. Take a look at the return information, which tells you the location of the extrated files. Take note and you"ll need it afterwards ! For me, my llvm folder locates at /usr/local/opt/llvm.
Compile YCMExcitingly, we are now good to compile the ycm_core library. Please refer to more information in instruction in Github.
First, confirm that where your youcompleteme folder locates, ~/.vim/bundle/youcompleteme for me.
Then, prepare for building files. In the terminal:
cd ~ mkdir ycm_build cd ycm_build
Since I DO care about semantic support for C-family (Hey, can anyone tell me what languages the "C-family" actually includes ???), make sure that you have your extracted files located at the right place. In the terminal:
cp -R /usr/local/opt/llvm ~/ycm_temp mv ~/ycm_temp/llvm ~/ycm_temp/llvm_root_dir
Now you should have the directorie at the right location. To assure you, the directory, llvm_root_dir, has something like bin, lib, and include etc, and now you have two filders named ycm_build and ycm_temp under ~/.
Inside the ycm_build directory, run in the terminal:
cd ~/ycm_build cmake -G "Unix Makefiles" -DPATH_TO_LLVM_ROOT=~/ycm_temp/llvm_root_dir . ~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp sudo cmake --build . --target ycm_core --config Release
"Unix Makefiles" is a generator tag. If you want to know more, please refer to instruction in Github.
Extra files to configureGood luck to you if you don"t have any errors. Now your YCM is supposed to work. But before we finish, we need to configure an extra file.
You can consider using YCM-Generator to generate the need file, accoding to the doc.
If you don"t want to bother with it, simply copy this file, put it at ~/.vim/.ycm_extra_conf.py", and lastly put let g:ycm_global_ycm_extra_conf = "~/.vim/.ycm_extra_conf.py" in your .vimrc.
YCM will recersively find the closest extra conf file, starting from the current location.
Congratulations, your YCM should work just fine.
Python quit unexpectedly every time I launch my MacVIMThis is probably you have linked YCM and MacVIM to different python. Try this:
cd /usr/local/Frameworks/Python.framework/Versions/2.7 cp Python Python_bak cd /System/Library/Framework/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS sudo cp Python Python_bak ln -sf Python /usr/local/Framework/Python.framework/Versions/2.7/Python
Reference
To be continuedThe actual efficiency needs to be tested, since I just finished the configuration myself.
How to generate personalized extra conf file.
9/25/2016
Weiming
文章版权归作者所有,未经允许请勿转载,若此文章存在违规行为,您可以联系管理员删除。
转载请注明本文地址:https://www.ucloud.cn/yun/24881.html
摘要:引言无疑是世界上最好用的编辑器之一为了不引起战争。本文将介绍一种推荐的代码补全工具,并且一步步介绍它的安装方式。是一个比较完备,并且正在日渐完备的代码补全插件。下面将介绍的安装及基本配置。 引言 Vim 无疑是世界上最好用的编辑器之一(为了不引起战争 →_→)。在广大程序员用 Vim 敲代码的过程中,代码补全功能能够大大提高生产力,尤其是对于从各种 IDE 转到 Vim 的程序员来说...
摘要:不过近日来随着最后几个补全插件的加入和配置调整,这个配置文件已经比较完整,因此可以好好坐下来,对使用方法和注意点作一介绍。更建议你打开里面的各个文件查看,学习。 中文介绍 原来的repo放在 spf13-vim-leoatchina,因为原来一时脑抽,把中文字体放进去后导致体积较大,影响速度,所以重开一个repo并把windows下的工具分开,以增加clone速度。 现在的配置是在 l...
阅读 3314·2021-11-10 11:36
阅读 3198·2021-10-08 10:21
阅读 2810·2021-09-29 09:35
阅读 2354·2021-09-22 16:06
阅读 3870·2021-09-09 09:33
阅读 1277·2019-08-30 15:44
阅读 3134·2019-08-30 10:59
阅读 2942·2019-08-29 15:32