#2022/10/13 coc.nvim更新了,按本文方法安裝后,無法正常使用,原因不明
第一步,安和裝nodejs和yarn
curl -fsSL https://deb.nodesource.com/setup_16.x | bash - &&\ apt-get install -y nodejs
curl --compressed -o- -L https://yarnpkg.com/install.sh | bash
deb.nodesource.com,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