ycm安装细则

本文介绍如何为Vim编辑器安装并配置YouCompleteMe(YCM)代码补全插件,包括安装必备条件、安装步骤及C系语言支持配置等。

before:

Ensure that your version of Vim is at least 7.4.1578 and that it has support for Python 2 or Python 3 scripting.

1.Install YCM

you can install it with Vundle (or Pathogen, but Vundle is a better idea)

but If you don't install YCM with Vundle, make sure you have run this command after checking out the YCM repository (Vundle will do this for you)

git submodule update --init --recursive

2.C-family languages(if you need)

    2.1、Download the latest version of libclang ->libclang下载

3.Compile the ycm_core library

    3.1  create a new folder where build files will be placed. Run the following:

cd ~
mkdir ycm_build
cd ycm_build

    3.2 generate the makefiles:

    if you don't need c-family languages:

    generator is "Unix Makefile" on unix-like os

cmake -G "<generator>" . ~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp

    if you need ,and you downloaded LLVM binary package, not a custom-built LLVM

cmake -G "<generator>" -DPATH_TO_LLVM_ROOT=~/ycm_temp/llvm_root_dir . ~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp

    if you have you use the system version of libclang, you would pass -DUSE_SYSTEM_LIBCLANG=ON to cmake instead ofthe -DPATH_TO_LLVM_ROOT=...

or you have a pre-built clang:

-DEXTERNAL_LIBCLANG_PATH=/path/to/libclang.so

For those who want to use the system version of boost, you would pass-DUSE_SYSTEM_BOOST=ON to cmake

NOTE: I STRONGLY recommend AGAINST use of the system boost/libclang insteadof the bundled version of boost/libclang


    3.3 build

cmake --build . --target ycm_core --config Release

4. Last

cp ~/.vim/bundle/YouCompleteMe/third_party/ycmd/examples/.ycm_extra_conf.py ~/.vim/



Ubuntu安装YouCompleteMe (YCM) 的步骤如下: 1. 安装Vim插件管理器Vundle:打开终端并输入以下命令: ``` git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim ``` 2. 配置.vimrc文件:打开终端并输入以下命令打开.vimrc文件: ``` vim ~/.vimrc ``` 在文件中添加以下内容: ``` set nocompatible " be iMproved, required filetype off " required " 设置Vundle运行时路径,并初始化Vundle set rtp+=~/.vim/bundle/Vundle.vim call vundle#begin() " 让Vundle管理插件 Plugin 'VundleVim/Vundle.vim' Plugin 'Valloric/YouCompleteMe' call vundle#end() " required filetype plugin indent on " required " 自定义配置如下: " ... 其他配置 ... " 开启YCM代码补全 let g:ycm_global_ycm_extra_conf = '~/.vim/bundle/YouCompleteMe/.ycm_extra_conf.py' let g:ycm_key_list_select_completion = ['<C-n>', '<Down>'] let g:ycm_key_list_previous_completion = ['<C-p>', '<Up>'] let g:ycm_min_num_of_chars_for_completion = 2 let g:ycm_filetype_blacklist = {} let g:ycm_filetype_whitelist = {} ``` 3. 保存并退出.vimrc文件,然后重新打开终端。 4. 安装YCM的依赖项:输入以下命令安装YCM的依赖项: ``` sudo apt-get install build-essential cmake python3-dev ``` 5. 编译YCM插件:在终端中输入以下命令: ``` cd ~/.vim/bundle/YouCompleteMe python3 install.py --clang-completer ``` 这会编译YCM插件并安装必要的补全引擎。 6. 重新启动Vim:打开Vim并输入以下命令来安装插件: ``` :PluginInstall ``` 插件安装完成后,重启Vim即可开始使用YCM
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值