首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >搭建vim-go环境

搭建vim-go环境

作者头像
超级大猪
发布2019-11-22 00:14:25
8380
发布2019-11-22 00:14:25
举报
文章被收录于专栏:大猪的笔记大猪的笔记

安装插件

首先安装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 <vim5632@rainslide.net>"
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 = '<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
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2019-06-25 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 安装插件
  • 修改配置
  • 开始安装
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档