搭建vim-go环境 ## 安装插件 首先安装vim最新版和bundle插件([链接](https://www.superpig.win/blog/details/rnfjrjgs "链接")) ## 修改配置 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 " 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\+$\| \+\ze\t\+\|\t\+\zs \+/ let g:ctrlp_map = '' let g:ctrlp_cmd = 'CtrlP' let g:ctrlp_custom_ignore = '\v[\/]\.(git|hg|svn|pyc)$' nmap :TagbarToggle map :NERDTreeToggle let g:NERDTreeWinSize = 15 let NERDTreeIgnore = ['.*\.o$','.*\.ko$','.*\.gz$','.*\.pyc$'] " 设置vim-go跳转定义,;gd nnoremap gd :GoDef " . 后面自动弹出代码提示 au filetype go inoremap . . " ctrl-z 自动弹出代码提示 imap " 只弹出代码提示,不补全 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 s :call ToggleErrors() "默认打开NERDTree func StartNerdTree() if &filetype == 'py'||&filetype == 'python'||&filetype == 'go' NERDTree endif endfunc autocmd vimenter * call StartNerdTree() " vim tab,使用 ;1 ;2跳tab noremap 1 1gt noremap 2 2gt noremap 3 3gt noremap 4 4gt noremap 5 5gt noremap 6 6gt noremap 7 7gt noremap 8 8gt noremap 9 9gt ``` ## 开始安装 打开vim ``` :PluginInstall :GoInstallBinaries ``` 来自 大脸猫 写于 2019-06-25 12:59 -- 更新于2020-10-19 13:06 -- 0 条评论