在本身的環境變量中配置好go的pathnode
77 export GOROOT=/usr/local/go 78 export PATH=$PATH:$GOROOT/bin 79 export GOPATH=/data/gowork
1.在官網下載 nvim-linux64.tar.gz 這個安裝包
tar -zxvf nvim-linux64.tar.gz 解壓後使用 ln -s創建連接python
ln -s /root/nvim/nvim-linux64/bin/nvim nvim #在配置文件中添加聲明,使nvim成爲關鍵字 export PATH=$PATH:/root/nvim/nvim-linux64/bin
而後就能夠像使用vim同樣使用nvim了linux
由於後續安裝的一些代碼補全插件須要這兩個組件的支持,因此先提早安裝git
1.先去https://npm.taobao.org/mirror...
2.tar zxvf 解壓到想要存放的文件目錄下
3.在/etc/profile 文件中聲明github
export PATH=$PATH:/root/node/node-v14.16.1-linux-x64/bin
4.設立連接golang
ln -s /root/node/node-v14.16.1-linux-x64/bin/npm ~/npm ln -s /root/node/node-v14.16.1-linux-x64/bin/node ~/node #source 讓配置的path生效 source /etc/profile
[root@VM-0-16-centos ~]# npm -v 6.14.12 [root@VM-0-16-centos ~]# node -v v14.16.1 檢查版本成功即安裝成功
1.下載python安裝包
https://www.python.org/ftp/py...typescript
2.tar -xzf Python-3.8.6rc1.tgz
3.進入解壓完的目錄 執行以下命令, 路徑爲想安裝的py路徑
./configure --prefix="/root/python3.8"
4.等執行完後繼續在解壓完的目錄下依次執行
make
make install
5.編譯完成後在環境變量中添加npm
alias python3=/root/python3.8/bin/python3.8 alias pip3=/root/python3.8/bin/pip3.8
而後查看
pthone3 -v
pip3 -v
檢驗安裝成功json
1.建立 mkdir -p ~/./config/nvim 文件夾
而後在~/./config/nvim中建立vim
2.git clone https://github.com/junegunn/v...
進入vim-plug目錄將 plug.vim這個文件拷貝到剛剛建立的autoload文件夾中
3.nvim 打開init.vim
輸入
" 插件開始的位置 call plug#begin('~/.vim/plugged') Plug 'fatih/vim-go', { 'tag': '*' } Plug 'neoclide/coc.nvim',{'branch':'release'} Plug 'Valloric/YouCompleteMe' " 插件結束的位置,插件所有放在此行上面 call plug#end()
這三個是go的主要插件
這個是vim-go相關的配置,也是寫在init.vim裏就好了。(不要和插件內容寫混了)
" vim-go let g:go_fmt_command = 'goimports' let g:go_autodetect_gopath = 1 " let g:go_bin_path = '$GOBIN' let g:go_highlight_types = 1 let g:go_highlight_fields = 1 let g:go_highlight_functions = 1 let g:go_highlight_function_calls = 1 let g:go_highlight_extra_types = 1 let g:go_highlight_generate_tags = 1 " Open :GoDeclsDir with ctrl-g nmap <C-g> :GoDeclsDir<cr> imap <C-g> <esc>:<C-u>GoDeclsDir<cr> augroup go autocmd! autocmd BufNewFile,BufRead *.go setlocal noexpandtab tabstop=4 shiftwidth=4 augroup END
4.而後打開一個nvim窗口,在命令模式下輸入 PlugInstall 安裝插件
5.安裝完畢後再在命令模式下輸入 GoInstallBinaries 安裝vim-go所須要的一些插件
這個默認是安裝在gobin目錄下的,若是下載失敗輸入
export GOPROXY=https://goproxy.io,direct
再重試下
6.再打開nvim 在命令模式下輸入 CocInstall coc-go coc-json coc-snippets coc-yaml
安裝coc相關的插件
最後是一些init.vim的配置
"============================================================================== " vim 基礎配置 "============================================================================== "顯示行號 set number "開啓語法高亮 set syntax=on "設置以unix的格式保存文件" set fileformat=unix "設置table長度 set tabstop=4 "同上 set shiftwidth=4 "文件編碼 set fenc=utf-8 "啓用鼠標 set mouse=a "突出顯示當前行 "set cursorline "文件編碼 set encoding=utf-8 "自動縮進 set autoindent set softtabstop=4 "自動縮進所使用的空白長度指示 set shiftwidth=4 set expandtab "============================================================================== " vim plug "============================================================================== call plug#begin('~/.vim/plugged') Plug 'scrooloose/nerdtree' Plug 'vim-airline/vim-airline' Plug 'vim-airline/vim-airline-themes' Plug 'mhinz/vim-startify' Plug 'fatih/vim-go' Plug 'neoclide/coc.nvim', {'branch': 'release'} call plug#end() "============================================================================== " vim plug config "============================================================================== "---------------------------------------------------------------------------- " NERDTree config "---------------------------------------------------------------------------- " F2鍵快速調出和隱藏它 map <F2> :NERDTreeToggle<CR> " 關閉vim時,若是打開的文件除了NERDTree沒有其餘文件時,它自動關閉,減小屢次按:q! autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif " 打開vim時自動打開NERDTree autocmd vimenter * NERDTree "設定 NERDTree 視窗大小 let g:NERDTreeWinSize = 25 "---------------------------------------------------------------------------- " vim-go config "---------------------------------------------------------------------------- let g:go_fmt_command = 'goimports' let g:go_autodetect_gopath = 1 " let g:go_bin_path = '$GOBIN' let g:go_highlight_types = 1 let g:go_highlight_fields = 1 let g:go_highlight_functions = 1 let g:go_highlight_function_calls = 1 let g:go_highlight_extra_types = 1 let g:go_highlight_generate_tags = 1 " Open :GoDeclsDir with ctrl-g nmap <C-g> :GoDeclsDir<cr> imap <C-g> <esc>:<C-u>GoDeclsDir<cr> augroup go autocmd! autocmd BufNewFile,BufRead *.go setlocal noexpandtab tabstop=4 shiftwidth=4 augroup END "---------------------------------------------------------------------------- " coc.vim config "---------------------------------------------------------------------------- " TextEdit might fail if hidden is not set. set hidden " Some servers have issues with backup files, see #649. set nobackup set nowritebackup " Give more space for displaying messages. set cmdheight=2 " Having longer updatetime (default is 4000 ms = 4 s) leads to noticeable " delays and poor user experience. set updatetime=300 " Don't pass messages to |ins-completion-menu|. set shortmess+=c " Always show the signcolumn, otherwise it would shift the text each time " diagnostics appear/become resolved. if has("patch-8.1.1564") " Recently vim can merge signcolumn and number column into one set signcolumn=number else set signcolumn=yes endif " Use tab for trigger completion with characters ahead and navigate. " NOTE: Use command ':verbose imap <tab>' to make sure tab is not mapped by " other plugin before putting this into your config. 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 " Use <c-space> to trigger completion. if has('nvim') inoremap <silent><expr> <c-space> coc#refresh() else inoremap <silent><expr> <c-@> coc#refresh() endif " Use <cr> to confirm completion, `<C-g>u` means break undo chain at current " position. Coc only does snippet and additional edit on confirm. " <cr> could be remapped by other vim plugin, try `:verbose imap <CR>`. if exists('*complete_info') inoremap <expr> <cr> complete_info()["selected"] != "-1" ? "\<C-y>" : "\<C-g>u\<CR>" else inoremap <expr> <cr> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>" endif " 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) " GoTo code navigation. nmap <silent> gd <Plug>(coc-definition) nmap <silent> gy <Plug>(coc-type-definition) nmap <silent> gi <Plug>(coc-implementation) nmap <silent> gr <Plug>(coc-references) " 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>') else call CocAction('doHover') endif endfunction " Highlight the symbol and its references when holding the cursor. autocmd CursorHold * silent call CocActionAsync('highlight') " Symbol renaming. nmap <leader>rn <Plug>(coc-rename) " Formatting selected code. xmap <leader>f <Plug>(coc-format-selected) nmap <leader>f <Plug>(coc-format-selected) augroup mygroup autocmd! " Setup formatexpr specified filetype(s). autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected') " Update signature help on jump placeholder. autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp') augroup end " Applying codeAction to the selected region. " Example: `<leader>aap` for current paragraph xmap <leader>a <Plug>(coc-codeaction-selected) nmap <leader>a <Plug>(coc-codeaction-selected) " Remap keys for applying codeAction to the current buffer. nmap <leader>ac <Plug>(coc-codeaction) " Apply AutoFix to problem on the current line. nmap <leader>qf <Plug>(coc-fix-current) " Map function and class text objects " NOTE: Requires 'textDocument.documentSymbol' support from the language server. xmap if <Plug>(coc-funcobj-i) omap if <Plug>(coc-funcobj-i) xmap af <Plug>(coc-funcobj-a) omap af <Plug>(coc-funcobj-a) xmap ic <Plug>(coc-classobj-i) omap ic <Plug>(coc-classobj-i) xmap ac <Plug>(coc-classobj-a) omap ac <Plug>(coc-classobj-a) " Use CTRL-S for selections ranges. " Requires 'textDocument/selectionRange' support of LS, ex: coc-tsserver nmap <silent> <C-s> <Plug>(coc-range-select) xmap <silent> <C-s> <Plug>(coc-range-select) " Add `:Format` command to format current buffer. command! -nargs=0 Format :call CocAction('format') " Add `:Fold` command to fold current buffer. command! -nargs=? Fold :call CocAction('fold', <f-args>) " Add `:OR` command for organize imports of the current buffer. command! -nargs=0 OR :call CocAction('runCommand', 'editor.action.organizeImport') " Add (Neo)Vim's native statusline support. " NOTE: Please see `:h coc-status` for integrations with external plugins that " provide custom statusline: lightline.vim, vim-airline. set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')} " Mappings for CoCList " Show all diagnostics. nnoremap <silent><nowait> <space>a :<C-u>CocList diagnostics<cr> " Manage extensions. nnoremap <silent><nowait> <space>e :<C-u>CocList extensions<cr> " Show commands. nnoremap <silent><nowait> <space>c :<C-u>CocList commands<cr> " Find symbol of current document. nnoremap <silent><nowait> <space>o :<C-u>CocList outline<cr> " Search workspace symbols. nnoremap <silent><nowait> <space>s :<C-u>CocList -I symbols<cr> " Do default action for next item. nnoremap <silent><nowait> <space>j :<C-u>CocNext<CR> " Do default action for previous item. nnoremap <silent><nowait> <space>k :<C-u>CocPrev<CR> " Resume latest coc list. nnoremap <silent><nowait> <space>p :<C-u>CocListResume<CR>
參考:
https://pokitpeng.github.io/p...
https://learnku.com/articles/...