ycm安装细则

本文介绍如何安装YouCompleteMe插件并设置C/C++语义补全功能,包括从GitHub克隆插件、配置编译环境、安装依赖库以及设置额外配置文件等步骤。

#安装vim-plug或者vundle(可选)
#你需要安装cmake来进行下面的工作

1、安装ycm
    1.1、从github安装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、添加c/c++语义补全

(推荐下载二进制包,当然你也可以直接编译安装clang和llvm),下载地址clang+llvm。你可能还需要python-devpython3-dev



cd ~ mkdir ycm_build cd ycm_build

然后讲你下载的文件里的内容解压,‘~/ycm_temp/llvm_root_dir’为你解压后的文件目录


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


如果你是编译安装的话


cmake -G "<generator>" DEXTERNAL_LIBCLANG_PATH=“你的libclang.so的位置” . ~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp

构建ycm_core

# --config Release 这个构建选项进针对 Windows $ cmake --build . --target ycm_core --config Release



3、配置
复制 .ycm_extra_conf.py 文件

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



参考:https://github.com/Valloric/YouCompleteMe/blob/master/README.md
https://www.v2ex.com/t/341751
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、付费专栏及课程。

余额充值