YouCompleteMe | 安装过程记录 2021

YCM

托管库地址:https://github.com/ycm-core/YouCompleteMe
这里有英文描述的安装过程,分别对于:Win, Linux, BSD描述

以下是我的个人安装过程

环境配置

确认下列环境已经安装:

  • 工具:Git
  • 开发环境:MSVC(Visual Studio自带), CMake, Python, Go, Node.JS
  • Vim插件:vim-plug

注意:python版本是3,并且受所安装Vim的支持
可通过:version查看支持的版本,:echo has('python3') 查看当前python环境是否可用于Vim。

安装

在 _vimrc 中添加:

set encoding=utf-8

vim-plug加载插件的区域中添加ycm插件记录:

call plug#begin('$VIM/vimfiles/plugged')
...
Plug 'ycm-core/YouCompleteMe'
...
call plug#end()

重载_vimrc::so %

执行::PlugInstall调用vim-plug安装函数,开始从github克隆到本地

由于连接github经常断线,手动到插件目录(vimfiles\plugged\YouCompleteMe)查看状态,提示我执行:
git submodule update --init --recursive

git报错:

fatal: unable to access 'https://github.com/gorakhargosh/watchdog/': OpenSSL SSL_read: Connection was reset, errno 10054
Failed to clone 'third_party/watchdog_deps/watchdog'. Retry scheduled ...

由于众所周知的原因,连接github的网络经常会被重置,多试几次

断续下载了一些文件

到这个第三方模块时,重新尝试一直报错:

fatal: could not get a repository handle for submodule 'third_party/mrab-regex'
Failed to recurse into submodule path 'third_party/ycmd'

...
fatal: not a git repository: D:/Software/Vim/vimfiles/plugged/YouCompleteMe/third_party/ycmd/third_party/mrab-regex/../../../../.git/modules/third_party/ycmd/modules/third_party/mrab-regex
Failed to clone 'third_party/mrab-regex'. Retry scheduled

打开YCM的仓库一看,发现mrab-regex已经放到bitbucket托管了

进入ycmd/modules/third_party/mrab-regex目录,在此执行:
git clone https://bitbucket.org/mrabarnett/mrab-regex.git

后续显示:

Submodule path 'third_party/ycmd/third_party/mrab-regex': checked out 'fa9def53cf920ed9343a0afab54d5075d4c75394'
Submodule path 'third_party/ycmd/third_party/watchdog_deps/watchdog': checked out '5fbd4b689ab86cef21834d6359969bd57f20dab0'

应该就是这些模块已经克隆成功了

所有文件克隆到本地后,进入插件目录(.../plugged/YouCompleteMe/)

先确认要补全的语言环境:
对应的脚本执行参数:

  • C/C++(C-family): --clangd-completer
  • C#: --cs-completer
  • TypeScript/JS: --ts-completer

其他语言选项可进仓库查看官方说明

执行:python3 install.py [lang-option]

比如:安装YCM同时安装C系列语言的补全:python3 install.py --clangd-completer

自动下载安装clangd:

Downloading Clangd from https://github.com/ycm-core/llvm/releases/download/12.0.0/clangd-12.0.0-win64.tar.bz2...
Extracting Clangd to D:\Software\Vim\vimfiles\plugged\YouCompleteMe\third_party\ycmd\third_party\clangd\output...
Done installing Clangd

此处的clangd是LLVM的分析后端程序,通过LSP(Language Server Protocol)与前端(编辑器插件)通信

安装好后重新加载_vimrc配置就可使用了

image

posted @ 2021-06-30 15:04  windin  阅读(1048)  评论(0编辑  收藏  举报