资讯专栏INFORMATION COLUMN

How did I install Youcompleteme

TalkingData / 917人阅读

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.

Specifications

Mac 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 MacVim

First 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 Vundle

The 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 Brew

CMake 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 completion

This 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 YCM

Excitingly, 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 configure

Good 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 MacVIM

This 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 continued

The 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作为一个强大的编辑器,再配合强大的插件,就可以称得上为编辑神器了。 pathogen pathogen为管理插件的插件,类似的还有vundle。在 Pathogen 之前,安装插件就是把插件文件放在.vim目录...

    dackel 评论0 收藏0
  • Mac 下配置 Vim 代码补全:YouCompleteMe

    摘要:引言无疑是世界上最好用的编辑器之一为了不引起战争。本文将介绍一种推荐的代码补全工具,并且一步步介绍它的安装方式。是一个比较完备,并且正在日渐完备的代码补全插件。下面将介绍的安装及基本配置。 引言 Vim 无疑是世界上最好用的编辑器之一(为了不引起战争 →_→)。在广大程序员用 Vim 敲代码的过程中,代码补全功能能够大大提高生产力,尤其是对于从各种 IDE 转到 Vim 的程序员来说...

    Simon_Zhou 评论0 收藏0
  • 我的vim配置文件,再度升级

    摘要:不过近日来随着最后几个补全插件的加入和配置调整,这个配置文件已经比较完整,因此可以好好坐下来,对使用方法和注意点作一介绍。更建议你打开里面的各个文件查看,学习。 中文介绍 原来的repo放在 spf13-vim-leoatchina,因为原来一时脑抽,把中文字体放进去后导致体积较大,影响速度,所以重开一个repo并把windows下的工具分开,以增加clone速度。 现在的配置是在 l...

    Simon_Zhou 评论0 收藏0

发表评论

0条评论

TalkingData

|高级讲师

TA的文章

阅读更多
最新活动
阅读需要支付1元查看
<