linweibin

  • 首页

  • 分类

  • 归档

  • 标签

  • 关于

Ubuntu14安装YouCompleteMe

发表于 2017-02-08 | 分类于 tech | 评论数: | 阅读次数:

YouCompleteMe是一款不错的vim代码补全插件,支持C/C++和python等语言的补全

安装

1: 首先安装vim的插件管理器Vundle,如果已经安装则跳过此步

1
git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim

2: 编辑~/.vimrc配置文件,在文件的最上面加入如下的配置

注意Plugin ‘Valloric/YouCompleteMe’这句话

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
set nocompatible              " be iMproved, required
filetype off " required

" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')

" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'

" The following are examples of different formats supported.
" Keep Plugin commands between vundle#begin/end.
" plugin YouCompleteMe
Plugin 'Valloric/YouCompleteMe'

" All of your Plugins must be added before the following line
call vundle#end() " required
filetype plugin indent on " required
" To ignore plugin indent changes, instead use:
"filetype plugin on
"
" Brief help
" :PluginList - lists configured plugins
" :PluginInstall - installs plugins; append `!` to update or just :PluginUpdate
" :PluginSearch foo - searches for foo; append `!` to refresh local cache
" :PluginClean - confirms removal of unused plugins; append `!` to auto-approve removal
"
" see :h vundle for more details or wiki for FAQ
" Put your non-Plugin stuff after this line

3:用Vundle安装YouCompleteMe插件

1
vim +PluginInstall +qall

4: 如果系统没有CMake,要先安装CMake

1
sudo apt-get install build-essential cmake

5: 如果系统没有python,要先安装python

1
sudo apt-get install python-dev python3-dev

6: 安装Clang,已对C/C++提供支持,这里看网速,可能会比较慢

1
2
cd ~/.vim/bundle/YouCompleteMe
./install.py --clang-completer

恭喜!如果你顺利走到这一步的话,说明YouCompleteMe已经安装完成了!

配置

如果是采用CMake编译代码的话,可以采用下面的方法来配置,其他编译方法可以参考官方的文档

1: 在CMakeLists.txt里面添加下面一行配置

1
set( CMAKE_EXPORT_COMPILE_COMMANDS ON )

2: 编译工程,查找目录下面生成的compile_commands.json这个文件

3:在工程根目录建立一个软连接到compile_commands.json这个文件就行了

1
2
cd ~/your_project_root_path
ln -s ~/your_compile_commands_json_path/compile_commands.json compile_commands.json

4: 用vi打开C++文件,就可以看到代码补全了

Hello World

发表于 2017-02-07 | 分类于 tech | 评论数: | 阅读次数:

Welcome to Hexo! This is your very first post. Check documentation for more info. If you get any problems when using Hexo, you can find the answer in troubleshooting or you can ask me on GitHub.

Quick Start

Create a new post

1
$ hexo new "My New Post"

More info: Writing

Run server

1
$ hexo server

More info: Server

Generate static files

1
$ hexo generate

More info: Generating

Deploy to remote sites

1
$ hexo deploy

More info: Deployment

123

林伟彬

14 日志
3 分类
11 标签
GitHub E-Mail
© 2020 林伟彬
由 Hexo 强力驱动 v3.8.0
|
主题 – NexT.Gemini v7.0.0
|