golangVimVimgolang

电脑环境: Mac 10.13 + neovim

实现功能:

  • 代码高亮
  • 语法检查
  • 代码提示
  • 一个漂亮的主题
  • 快速的启动体验

核心插件:
vim-go、gruvbox、deoplete.nvim、ALE ...

使用Neovim

vim
brew install neovimneovimnvimVim~/.config/nvim/init.vim
set runtimepath^=~/.vim runtimepath+=~/.vim/after
let &packpath = &runtimepath
source ~/.vimrc
vim

安装 vim-plug

vim

1.安装

curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
    https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
.vimrc~/.config/nvim/init.vim
filetype plugin indent on
syntax on
call plug#begin('~/.vim/plugged)
Plug 'fatih/vim-go'
call plug#end()
:PlugInstall

安装 vim-go

vim-govim:help vim-go.txt
.

代码补全插件

deoplete.nvim

安装 deoplete.nvim 可以实现代码实时提示功能。

neovim/Vim8YouCompleteMe
For Plug
if has('nvim')
  Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
else
  Plug 'Shougo/deoplete.nvim'
  Plug 'roxma/nvim-yarp'
  Plug 'roxma/vim-hug-neovim-rpc'
endif
deoplete.nvimpython3
python3:echo has("python3")1

可以使用下面命令安装所需要的模块.

brew install python3

pip3 install neovim --user
deoplete.nvim 设置
deoplete.nvim
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>"

deoplete-go

下面使用deoplete-go

pip2 install --upgrade neovim
pip3 install --upgrade neovim
go get -u github.com/nsf/gocode
deoplete-govim-plug
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
Plug 'zchee/deoplete-go', { 'do': 'make'}
:PlugInstall
deoplete-go
" deoplete-go settings
let g:deoplete#sources#go#gocode_binary = $GOPATH.'/bin/gocode'
let g:deoplete#sources#go#sort_class = ['package', 'func', 'type', 'var', 'const']

UltiSnips & vim-snippets

Sirver/ultisnipshonza/vin-snippets
deoplete.nvimUltiSnips
let g:UltiSnipsExpandTrigger="<leader><tab>"
let g:UltiSnipsJumpForwardTrigger="<tab>"
let g:UltiSnipsJumpBackwardTrigger="<S-tab>"

语法检测

neovim/Vim8
vim-plug
Plug 'w0rp/ale' 
  1. 自定义
let g:ale_sign_error = ''
let g:ale_sign_warning = ''
let g:ale_completion_enabled = 1
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%]'
let g:ale_swift_swiftlint_use_defaults = 1
let g:ale_open_list = 0
let g:ale_lint_delay = 1000
let g:ale_linters = {
      \ 'go': ['golint', 'go vet', 'go build'],
      \ }
nmap ]a <Plug>(ale_next_wrap)
nmap [a <Plug>(ale_previous_wrap)

gruvbox 主题

Vim
Plug 'morhetz/gruvbox'colorscheme
colorscheme gruvbox
set background=dark
Vimvimrc

我的 .vimrc