ubantu安裝golang 與配置nvim

golang下載地址python

https://golang.google.cn/dl/linux

tar -C /usr/local -xzf go1.12.7.linux-amd64.tar.gzc++

// (1)用戶級別配置git

sudo vi $HOME/.profilegithub

export PATH=$PATH:/usr/local/go/bin:$GOPATH/bingolang

// (2)設置環境變量vim

export GOROOT=/usr/local/gocurl

export GOPATH=$HOME/gopost

// (3)生效配置ui

source $HOME/.profile

 


安裝gopm

go get -u github.com/gpmgo/gopm

  

安裝goTools

gopm get -g golang.org/x/tools
gopm get -g golang.org/x/lint

  

gopm get -g golang.org/x/sync/errgroup



go install golang.org/x/tools/cmd/guru
go install golang.org/x/tools/cmd/gorename
go install golang.org/x/tools/cmd/fiximports
go install golang.org/x/tools/cmd/gopls
go install golang.org/x/tools/cmd/godex

 

gocode
go get -u github.com/nsf/gocode

  

開啓關鍵字匹配
gocode set propose-builtins true

 


 

 配置neovim

在 ~/.config/nvim/init.vim 中添加  支持python3
let g:python3_host_prog = '/usr/local/bin/python3'

安裝vim-plug 

curl -fLo ~/.config/nvim/autoload/plug.vim --create-dirs \
    https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim

  

配置

filetype plugin indent on
syntax on
call plug#begin('~/.config/nvim/plugged)
Plug 'fatih/vim-go'
call plug#end()

使用命令安裝插件

 :PlugInstall 

 

安裝插件deoplete.nvim

deoplete.nvim 須要 python3 以及 neovim 的 python 模塊。

pip3 install neovim

 

在配置文件加入插件

Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
Plug 'zchee/deoplete-go', { 'do': 'make'}

  

 

官方配置

let g:deoplete#enable_at_startup = 1
inoremap <expr> <Tab> pumvisible() ? "\<C-n>" : "\<Tab>"
inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>"
inoremap <expr> <cr> pumvisible() ? "\<C-y>" : "\<cr>"

配置tab選擇

  

 

 安裝代碼補全神器Ultisnips與snippets

做用:只要敲幾個字母,自動生成一大段代碼 ,snippets是經常使用補全

Plugin 'SirVer/ultisnips'

Plugin 'honza/vim-snippets'

配置


let g:UltiSnipsExpandTrigger="<c-j>"
let g:UltiSnipsJumpForwardTrigger="<c-f>"
let g:UltiSnipsJumpBackwardTrigger="<c-b>"

  

語法檢查ALE

Plug 'w0rp/ale' 

 

"Ale                                         
  ""始終開啓標誌列       
  let g:ale_sign_column_always = 1                                                               
  let g:ale_set_highlights = 0    
  "自定義error和warning圖標                                        
  let g:ale_sign_error = '?'                   
  let g:ale_sign_warning = '?'    
  ""在vim自帶的狀態欄中整合ale    
  let g:ale_statusline_format = ['? %d', '? %d', '? OK']    
  "顯示Linter名稱,出錯或警告等相關信息    
  let g:ale_echo_msg_error_str = 'E'    
  let g:ale_echo_msg_warning_str = 'W'    
  let g:ale_echo_msg_format = '[%linter%] %s [%severity%]'    
  ""普通模式下,sp前往上一個錯誤或警告,sn前往下一個錯誤或警告    
  nmap sp <Plug>(ale_previous_wrap)    
  nmap sn <Plug>(ale_next_wrap)    
  "<Leader>s觸發/關閉語法檢查             
  nmap <Leader>s :ALEToggle<CR>                               
  ""<Leader>d查看錯誤或警告的詳細信息                             
  nmap <Leader>d :ALEDetail<CR>                             
  let g:ale_linters = {    
                          \   'c++': ['clang'],    
                          \   'c': ['clang'],                        
                          \   'python': ['pylint'],                                    
                          \   'go': ['golint', 'go vet', 'go build'],    
                          \}   

 

效果

 

美化插件gruvbox

Plug 'morhetz/gruvbox'

colorscheme gruvbox
set background=dark
相關文章
相關標籤/搜索