vim coc.nvim安装及配置c,c++补全

发布时间 2023-07-29 02:23:51作者: Uoyue

在安装之前需要安装npm yarn node.js

# 这里以ubuntu示例 
sudo apt install clang # 如果是c,c++补全需要安装
# 安装npm
sudo apt-get install npm
# 安装yarn
sudo npm install -g yarn
# 安装升级node.js到最新版本
sudo npm cache clean -f
sudo npm install -g n
sudo n stable
node -v

Vundle

添加下面的内容到.vimrc:

Plugin 'neoclide/coc.nvim'

VimPlug

添加下面的内容到.vimrc:

Plug 'neoclide/coc.nvim'

Vim 里面运行以下命令:

:source %
:PlugInstall

等待成功安装

Vim 里面运行以下命令:

:CocInstall coc-clangd

等待成功安装即可

可能遇到的问题

提示vim版本过低

# 更新版本vim版本
sudo add-apt-repository ppa:jonathonf/vim
sudo apt update
sudo apt upgrade

或者是

[coc.nvim] build/index.js not found, please install dependencies and compile coc.nvim by: yarn install

# 解决办法
# ~/.vim/bundle/coc.nvim/    #是我的coc.nvim插件的安装目录
cd ~/.vim/bundle/coc.nvim/	
yarn install
yarn build

参考文章

[coc.nvim] build/index.js not found, please install dependencies and compile coc.nvim by: yarn install
Press ENTER or type command to continue

上手Coc.nvim 完全指南