C/C++教程

vim安装coc插件自动补全

本文主要是介绍vim安装coc插件自动补全,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

第一步,安和装nodejs和yarn

curl -sL install-node.now.sh | bash 
curl --compressed -o- -L https://yarnpkg.com/install.sh | bash

 install-node.now.sh是一个网站,curl打开他的时候会下载一个sh文件,这两个名字可能需要sudo命令才能执行,并且| 后面的bash也要加sudo。

第二步,打开.vimrc文件,在vim.plug配置中安装coc.vim

call plug#begin()
" The default plugin directory will be as follows:
"   - Vim (Linux/macOS): '~/.vim/plugged'
"   - Vim (Windows): '~/vimfiles/plugged'
"   - Neovim (Linux/macOS/Windows): stdpath('data') . '/plugged'
" You can specify a custom plugin directory by passing it as the argument
"   - e.g. `call plug#begin('~/.vim/plugged')`
"   - Avoid using standard Vim directory names like 'plugin'

" Make sure you use single quotes

" Use release branch (recommend)
Plug 'neoclide/coc.nvim', {'branch': 'release'}

" Initialize plugin system
call plug#end()

保存退出后,在VIM普通模式中输入命令:

:PlugInstall##安装coc.nvim
:CocInfo##测试是否安装成功

第三步,安装coc语言扩展

#vim下输入
:CocInstall coc-clangd ##安装 C/C++/Objective-C 扩展

这里cocinstall会自动从https://registry.npmjs.org下载对应的语言扩展,但是网站被屏蔽,需要修改到阿里源。

修改npm方法:

1.原npm地址

npm config set registry http://registry.npmjs.org 

2.设置国内镜像

a.通过config命令

npm config set registry https://registry.npm.taobao.org 
npm info underscore (如果上面配置正确这个命令会有字符串response)

b.命令行指定

npm --registry https://registry.npm.taobao.org info underscore 

c.编辑 ~/.npmrc 加入下面内容

registry = https://registry.npm.taobao.org

3.使用nrm管理registry地址

a.下载nrm

npm install -g nrm

b.添加registry地址

nrm add npm http://registry.npmjs.org
nrm add taobao https://registry.npm.taobao.org

c.切换npm registry地址

nrm use taobao
nrm use npm
这篇关于vim安装coc插件自动补全的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!