搭建vim-go环境

  • 2019 年 11 月 22 日
  • 笔记

安装插件

首先安装vim最新版和bundle插件(链接

修改配置

cat ~/.vimrc

" 剪贴板设为系统  set clipboard=unnamedplus  " 打开鼠标控制  set mouse=a  set backspace=2  filetype off                  " required"  runtime! debian.vim  " 开始插件配置啦  set rtp+=~/.vim/bundle/Vundle.vim  call vundle#begin()  Plugin 'VundleVim/Vundle.vim'  Plugin 'ctrlpvim/ctrlp.vim'  Plugin 'majutsushi/tagbar'  Plugin 'scrooloose/nerdtree'  Plugin 'jiangmiao/auto-pairs'  Plugin 'fatih/vim-go'  Plugin 'scrooloose/syntastic'  Plugin 'mileszs/ack.vim'    call vundle#end() " required "  filetype plugin indent on " required "    if has("syntax")      syntax on  endif    " 自动删除多余空格  " From: Vigil <[email protected]>"  function RemoveTrailingWhitespace()      if &ft != "diff"          let b:curcol = col(".")          let b:curline = line(".")          silent! %s/s+$//          silent! %s/(s*n)+%$//          call cursor(b:curline, b:curcol)      endif  endfunction  autocmd BufWritePre * call RemoveTrailingWhitespace()    set ts=4  set sw=4    set nu  set autoindent  let mapleader=";"  highlight ExtraWhitespace ctermbg=red guibg=red  autocmd BufWinEnter * match ExtraWhitespace /s+$| +zet+|t+zs +/    let g:ctrlp_map = '<c-p>'  let g:ctrlp_cmd = 'CtrlP'  let g:ctrlp_custom_ignore = 'v[/].(git|hg|svn|pyc)$'  nmap <F8> :TagbarToggle<CR>  map <F10> :NERDTreeToggle<CR>  let g:NERDTreeWinSize = 15    let NERDTreeIgnore = ['.*.o$','.*.ko$','.*.gz$','.*.pyc$']    " 设置vim-go跳转定义,;gd  nnoremap <leader>gd :GoDef <CR>  " . 后面自动弹出代码提示  au filetype go inoremap <buffer> . .<C-x><C-o>  " ctrl-z 自动弹出代码提示  imap <c-z> <c-x><c-o>  " 只弹出代码提示,不补全  set completeopt=longest,menuone    " 语法检查插件的配置  let g:syntastic_error_symbol='>>'  let g:syntastic_warning_symbol='>'  let g:syntastic_check_on_open=1  let g:syntastic_check_on_wq=0  let g:syntastic_enable_highlighting=1  let g:syntastic_python_checkers=['pyflakes'] " 使用pyflakes,速度比pylint快  let g:syntastic_javascript_checkers = ['jsl', 'jshint']  let g:syntastic_html_checkers=['tidy', 'jshint']  " 修改高亮的背景色, 适应主题  highlight SyntasticErrorSign guifg=white guibg=black    " to see error location list  let g:syntastic_always_populate_loc_list = 0  let g:syntastic_auto_loc_list = 0  let g:syntastic_loc_list_height = 5  function! ToggleErrors()  let old_last_winnr = winnr('$')  lclose  if old_last_winnr == winnr('$')  " Nothing was closed, open syntastic error location panel          Errors      endif  endfunction  nnoremap <Leader>s :call ToggleErrors()<cr>    "默认打开NERDTree  func StartNerdTree()      if &filetype == 'py'||&filetype == 'python'||&filetype == 'go'          NERDTree      endif  endfunc  autocmd vimenter * call StartNerdTree()    " vim tab,使用 ;1 ;2跳tab  noremap <leader>1 1gt  noremap <leader>2 2gt  noremap <leader>3 3gt  noremap <leader>4 4gt  noremap <leader>5 5gt  noremap <leader>6 6gt  noremap <leader>7 7gt  noremap <leader>8 8gt  noremap <leader>9 9gt

开始安装

打开vim

:PluginInstall  :GoInstallBinaries