VIM插件环境安装

# 基础软件安装
apt install git gcc g++ gdb cmake global ripgrep clang-format clangd libreadline-dev libpython3-dev
# nodejs
curl -sL install-node.now.sh/lts | bash
# lua编译安装
wget http://www.lua.org/ftp/lua-5.4.3.tar.gz
tar -zxvf lua-5.4.3.tar.gz
cd lua-5.4.3
make linux
make install

VIM 配置文件

" base
colorscheme neodark
set number
set tabstop=4
set softtabstop=4
set autoindent
set nobackup
set noswapfile
set nocompatible 
set cursorline 
set ruler 
set shiftwidth=4 
set backupcopy=yes 
set incsearch
set hlsearch
set magic
set hidden
set smartindent 
set backspace=indent,eol,start
set cmdheight=2
set laststatus=2
set autoread
set encoding=utf-8
set termencoding=utf-8
set fencs=utf-8,gbk
set noesckeys
set nocompatible
set ttimeoutlen=100
set t_Co=256 
set completeopt =menu,menuone
set shortmess+=c
set updatetime=300
filetype plugin on

" plug
filetype off
call plug#begin('~/.vim/plugged')
Plug 'keitanakamura/neodark.vim'
Plug 'tpope/vim-commentary'
Plug 'Yggdroot/LeaderF', { 'do': './install.sh' }
Plug 'octol/vim-cpp-enhanced-highlight'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'rhysd/vim-clang-format'
Plug 'jiangmiao/auto-pairs'
Plug 'neoclide/coc.nvim', {'branch': 'release'}

call plug#end()
filetype plugin indent on

" leaderf
let g:Lf_Gtagslabel = 'native-pygments'
let g:Lf_GtagsAutoGenerate = 1
let g:Lf_ShortcutF = '<C-P>'
let g:Lf_StlSeparator = { 'left': '', 'right': '', 'font': '' }
let g:Lf_RootMarkers = ['.project', '.root', '.svn', '.git']
let g:Lf_WorkingDirectoryMode = 'Ac'
let g:Lf_WindowHeight = 0.30
let g:Lf_ShowRelativePath = 0
let g:Lf_HideHelp = 1
let g:Lf_UseCache = 0
let g:Lf_UseMemoryCache = 0
let g:Lf_UseVersionControlTool = 0
let g:Lf_IgnoreCurrentBufferName = 1
let g:Lf_PreviewResult = {'Function': 0, 'BufTag': 0 }
let g:Lf_JumpToExistingWindow = 0
let g:Lf_WindowPosition = 'popup'
let g:Lf_PreviewInPopup = 1

let g:Lf_WildIgnore = {
    \'dir': ['build', 'bin'],
    \'file': ['*.a', '*.lib', '*.so', '*.pb', '*.out', '*.o']
    \}

let g:Lf_RgConfig = [
    \ "--max-columns=150",
    \ "--glob=!build/*",
    \ "--glob=!bin/*",
    \ "--glob=!lib/*",
    \ "--glob=!cmake/*",
    \ ]

noremap <leader>gs :<C-U><C-R>=printf("Leaderf! rg --current-buffer -e %s ", expand("<cword>"))<CR><CR>
noremap <leader>gg :<C-U><C-R>=printf("Leaderf! rg -e %s ", expand("<cword>"))<CR><CR>
xnoremap gv :<C-U><C-R>=printf("Leaderf! rg -F -e %s ", leaderf#Rg#visual())<CR>
noremap gz :Leaderf! rg -F -e "
noremap <F5> :Leaderf gtags --update <CR>
noremap <F6> :Leaderf --recall <CR>

" airline
let g:airline_powerline_fonts = 1
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#left_sep = ''
let g:airline#extensions#tabline#left_alt_sep = ''
let g:airline#extensions#tabline#formatter = 'unique_tail'

" buffer
nnoremap <leader>[ :bp<CR>
nnoremap <leader>] :bn<CR>

" neodark
let g:lightline = {}
let g:lightline.colorscheme = 'neodark'
let g:neodark#use_256color = 1
let g:neodark#solid_vertsplit = 1
let g:neodark#use_custom_terminal_theme = 1

" clangformat
let g:clang_format#command = 'clang-format'
autocmd FileType c,cpp ClangFormatAutoEnable


" cpphighlight
let g:cpp_class_scope_highlight = 1
let g:cpp_member_variable_highlight = 1
let g:cpp_posix_standard = 1
let g:cpp_concepts_highlight = 1

" GoTo code navigation.
nmap <leader>gd <Plug>(coc-definition)
nmap <leader>gy <Plug>(coc-type-definition)
nmap <leader>gi <Plug>(coc-implementation)
nmap <leader>gr <Plug>(coc-references)

" Symbol renaming.
nmap <leader>rn <Plug>(coc-rename)

" Use K to show documentation in preview window.
nnoremap <silent> K :call <SID>show_documentation()<CR>

function! s:show_documentation()
  if (index(['vim','help'], &filetype) >= 0)
    execute 'h '.expand('<cword>')
  elseif (coc#rpc#ready())
    call CocActionAsync('doHover')
  else
    execute '!' . &keywordprg . " " . expand('<cword>')
  endif
endfunction

" Use `[g` and `]g` to navigate diagnostics
" Use `:CocDiagnostics` to get all diagnostics of current buffer in location list.
nmap <silent> [g <Plug>(coc-diagnostic-prev)
nmap <silent> ]g <Plug>(coc-diagnostic-next)

inoremap <silent><expr> <TAB>
      \ pumvisible() ? "\<C-n>" :
      \ <SID>check_back_space() ? "\<TAB>" :
      \ coc#refresh()
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"

function! s:check_back_space() abort
  let col = col('.') - 1
  return !col || getline('.')[col - 1]  =~# '\s'
endfunction

" Make <CR> auto-select the first completion item and notify coc.nvim to
" format on enter, <cr> could be remapped by other vim plugin
inoremap <silent><expr> <cr> pumvisible() ? coc#_select_confirm()
                              \: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
# 打开vim
vim v.vimrc
# 安装插件
PlugInstall
# 保存
# 重新打开vim
# 安装clang提示与补全 lua提示与补全
CocInstall coc-clangd coc-lua
# 安装clangd
CocComand clangd.install
# 填写配置文件
CocConfig
{
  "diagnostic":
  {
    "enableSign": "true",
    "errorSign": "✘",
    "warningSign": "!"
  },
  "Lua.diagnostics.disable" : [
        "lowercase-global"
  ],
  "pairs.enableBackspace": false,
  "clangd.path": "/root/.config/coc/extensions/coc-clangd-data/install/12.0.0/clangd_12.0.0/bin/clangd"
}