配置的比较简单,主要有三个功能:背景主题,目录树和代码补全(c++,python)
先安装vim-plug,用来管理插件 https://github.com/junegunn/vim-plug
先创建路径 ~/.vim/autoload
然后将vim-plug clone到本地,将本地仓库中的plug.vim文件拷贝到~/.vim/autoload/文件夹下
然后安装node
下载地址 https://nodejs.org/en/download/
用wget+下载地址下载到本地,然后创建路径
sudo mkdir -p /usr/local/lib/nodejs
然后将node解压到指定路径
sudo tar -xJvf node-v18.12.1-linux-x64.tar.xz -C /usr/local/lib/nodejs
在~/.bashrc中设置环境变量
export PATH=$PATH:/usr/local/lib/nodejs/node-v18.12.1-linux-x64/bin
就ok了
如何安装vim-plug的插件
进入vim,在命令模式下输入PlugInstall,就会自动安装,需要利用vim-plug安装一个叫做coc的插件,在命令模式下输入CocInfo查看是否安装成功
在vim插件的网址,可以在里面找各种插件,使用vim-plug安装 https://vimawesome.com/
在coc_global_extensions中配置需要的coc插件,配置好之后下次进入vim会自动安装,其中coc-clangd是c++补全插件,使用coc-clangd还需要用apt安装clangd
sudo apt install clangd
安装完之后,vim就可以成功补全c++代码了,完整配置文件如下
" line number set number " tab = 4 space set tabstop=4 set shiftwidth=4 " allow user edit other file when current file was not saved set hidden " faster response of vim set updatetime=100 " hide vim-coc warning let g:coc_disable_startup_warning = 1 " plug-in call plug#begin('~/.vim/plugged') Plug 'tpope/vim-sensible' Plug 'junegunn/seoul256.vim' Plug 'neoclide/coc.nvim', {'branch': 'release'} Plug 'scrooloose/nerdtree' call plug#end() " use Ctrl+n to open or close NERDTree nnoremap <f2> :NERDTreeToggle<CR> " seoul256 (dark): " Range: 233 (darkest) ~ 239 (lightest) " Default: 237 let g:seoul256_background = 233 colo seoul256 " coc plug-in setting let g:coc_global_extensions =[ \ 'coc-json', \ 'coc-vimlsp', \ 'coc-clangd', \ 'coc-pyright'] " Make <CR> to accept selected completion item or notify coc.nvim to format " <C-g>u breaks current undo, please make your own choice inoremap <silent><expr> <CR> coc#pum#visible() ? coc#pum#confirm() \: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
标签:plug,插件,set,配置,vim,coc,安装 From: https://www.cnblogs.com/wangtianning1223/p/16991969.html