折腾了 3天终于找到一个 goLang vim的好配置了
git clone https://github.com/gmarik/Vundle.vim.git ~/.vim/bundle/Vundle.vim
首先添加 Vundle 管理工具
vim 直接用yum 添加就可以了
然后修改家目录下面的 .vimrc文件
syntax on " set color theme "colorscheme busybee set background=dark " solarized options colorscheme solarized " Configuration section of vundle filetype off " required! set rtp+=~/.vim/bundle/Vundle.vim call vundle#begin() " let Vundle manage Vundle " required! Plugin 'VundleVim/Vundle.vim' " My Bundles here: Plugin 'mileszs/ack.vim' Plugin 'mattn/emmet-vim' Plugin 'ervandew/supertab' Plugin 'scrooloose/nerdtree' Plugin 'scrooloose/nerdcommenter' Plugin 'majutsushi/tagbar' Plugin 'kien/ctrlp.vim' Plugin 'vim-scripts/xml.vim' Plugin 'jiangmiao/auto-pairs' Plugin 'flazz/vim-colorschemes' Plugin 'honza/vim-snippets' Plugin 'tpope/vim-dispatch' Plugin 'tpope/vim-fugitive' Plugin 'tpope/vim-surround' Plugin 'tpope/vim-repeat' Plugin 'tpope/vim-rails' Plugin 'bling/vim-airline' Plugin 'Lokaltog/vim-easymotion' Plugin 'TimothyYe/vim-tips' Plugin 'Shougo/neocomplete' Plugin 'mhinz/vim-startify' Plugin 'vim-scripts/wildfire.vim' Plugin 'nathanaelkane/vim-indent-guides' Plugin 'yonchu/accelerated-smooth-scroll' Plugin 'ianva/vim-youdao-translater' Plugin 'elixir-lang/vim-elixir' Plugin 'matze/vim-move' " For fun... Plugin 'uguu-org/vim-matrix-screensaver' "Plugins for golang Plugin 'fatih/vim-go' "goimports settings "autocmd BufWritePre *.go :Fmt call vundle#end() filetype plugin indent on " required! " End of vundle configuration let g:airline_theme='light' let g:neocomplete#enable_at_startup = 1 let g:neocomplete#enable_smart_case = 1 let g:neocomplete#sources#syntax#min_keyword_length = 2 "For vim-move let g:move_key_modifier = 'C' "For ack let g:ackprg = 'ag --nogroup --nocolor --column' "Settings for Golang let g:go_fmt_command = "goimports" let g:go_highlight_functions = 1 let g:go_highlight_methods = 1 let g:go_highlight_structs = 1 let g:go_highlight_operators = 1 let g:go_highlight_build_constraints = 1 au FileType go nmap <Leader>i <Plug>(go-info) au FileType go nmap <Leader>gd <Plug>(go-doc) au FileType go nmap <leader>r <Plug>(go-run) au FileType go nmap <leader>b <Plug>(go-build) au FileType go nmap <leader>t <Plug>(go-test) au FileType go nmap <leader>c <Plug>(go-coverage) au FileType go nmap gd <Plug>(go-def-tab) "For Youdao Translater Plugin vnoremap <silent> <C-T> <Esc>:Ydv<CR> nnoremap <silent> <C-T> <Esc>:Ydc<CR> inoremap jj <Esc> "Powerline setting "Set GUI font type if has("gui_running") set guifont=Source\ Code\ Pro\:h18 endif let g:airline_powerline_fonts = 1 "improve autocomplete menu color highlight Pmenu ctermbg=238 gui=bold "Setup SuperTab let g:SuperTabRetainCompletionType="context" "For Indent Guides Plugin let g:indent_guides_enable_on_vim_startup = 1 " 设定文件浏览器目录为当前目录 set bsdir=buffer " 设置编码 set encoding=utf-8 set nocompatible set laststatus=2 " 设置文件编码 set fenc=utf-8 "set to use clipboard of system set clipboard=unnamed " 设置文件编码检测类型及支持格式 set fencs=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936 "显示行号 set number "Show related row numbers set relativenumber "settings for backspace set backspace=2 set backspace=indent,eol,start "忽略大小写查找 set ic " tab宽度 set tabstop=2 set cindent shiftwidth=2 set autoindent shiftwidth=2 " set 折叠 set foldmethod=indent " 打开文件默认不折叠 set foldlevelstart=99 "set my leader let mapleader="\<Space>" let g:mapleader="\<Space>" "tabs nmap <leader>tn :tabnew<cr> nmap <leader>te :tabedit nmap <leader>tc :tabclose<cr> nmap <leader>tm :tabmove " 映射NERDTree插件 :map <leader>n :NERDTree<CR> "let loaded_nerd_tree=1 let NERDTreeQuitOnOpen = 1 let NERDChristmasTree=1 let g:NERDTreeWinSize = 32 map <leader>f :NERDTreeToggle<CR> " Settings for vim-easymotion let g:EasyMotion_leader_key = "," "Settings for TagBar map <leader>g :TagbarToggle<CR> let g:tagbar_type_go = { \ 'ctagstype' : 'go', \ 'kinds' : [ \ 'p:package', \ 'i:imports:1', \ 'c:constants', \ 'v:variables', \ 't:types', \ 'n:interfaces', \ 'w:fields', \ 'e:embedded', \ 'm:methods', \ 'r:constructor', \ 'f:functions' \ ], \ 'sro' : '.', \ 'kind2scope' : { \ 't' : 'ctype', \ 'n' : 'ntype' \ }, \ 'scope2kind' : { \ 'ctype' : 't', \ 'ntype' : 'n' \ }, \ 'ctagsbin' : 'gotags', \ 'ctagsargs' : '-sort -silent' \ } "switch window :map <leader>w <C-W>w "set zen coding let g:user_zen_settings = { \ 'php' : { \ 'extends' : 'html', \ 'filters' : 'c', \ }, \ 'xml' : { \ 'extends' : 'html', \ }, \ 'haml' : { \ 'extends' : 'html', \ }, \ 'erb' : { \ 'extends' : 'html', \ }, \} "set CtrlP let g:ctrlp_map = '<c-p>' let g:ctrlp_cmd = 'CtrlP' let g:ctrlp_custom_ignore = '\.git$\|\.hg$\|\.svn$\|.rvm$' let g:ctrlp_working_path_mode=0 let g:ctrlp_match_window_bottom=1 let g:ctrlp_max_height=15 let g:ctrlp_match_window_reversed=0 let g:ctrlp_mruf_max=500 let g:ctrlp_follow_symlinks=1 "use in edit imap <C-A> <C-C><c-p> set wildignore+=*/tmp/*,*.so,*.swp,*.zip,*.jpg,*.png,*.gif,*.jpeg,.DS_Store " MacOSX/Linux let g:ctrlp_custom_ignore = '\.git$\|\.hg$\|\.svn$' " move lines up or down (command - D) nmap <D-j> mz:m+<cr>`z nmap <D-k> mz:m-2<cr>`z vmap <D-j> :m'>+<cr>`<my`>mzgv`yo`z vmap <D-k> :m'<-2<cr>`>my`<mzgv`yo`z " Tab move lines left or right (c-Ctrl,s-Shift) nmap <c-tab> v> nmap <s-tab> v< vmap <c-tab> >gv vmap <s-tab> <gv " tab navigation like zsh :nmap <leader>h :tabprevious<CR> :nmap <leader>l :tabnext<CR> " settings for resize splitted window nmap w[ :vertical resize -3<CR> nmap w] :vertical resize +3<CR> nmap w- :resize -3<CR> nmap w= :resize +3<CR> "markdown hightlight let g:octopress_rake_executable = '/usr/bin/rake' "scss,sass au BufRead,BufNewFile *.scss set filetype=scss au BufRead,BufNewFile *.sass set filetype=scss "coffee script au BufWritePost *.coffee silent CoffeeMake! au BufWritePost *.coffee :CoffeeCompile watch vert "let skim use slim syntax au BufRead,BufNewFile *.skim set filetype=slim "ctags set tags+=~/gitdb/rails/tags "auto completed " Disable AutoComplPop. let g:acp_enableAtStartup = 0 " Enable omni completion. autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS autocmd FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS autocmd FileType python setlocal omnifunc=pythoncomplete#Complete autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags " Enable heavy omni completion. if !exists('g:neocomplcache_omni_patterns') let g:neocomplcache_omni_patterns = {} endif let g:neocomplcache_omni_patterns.ruby = '[^. *\t]\.\w*\|\h\w*::' " code search let g:ackprg = 'ag --nogroup --nocolor --column' silent! call repeat#set("\<Plug>MyWonderfulMap", v:count) " For startify
修改完成后。直接使用vim一下
然后在命令运行 :PluginInstall
等待完成插件安装。打开go文件查看效果