搭建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