Created
March 28, 2015 04:48
-
-
Save rainyear/037de9035b236ad251e6 to your computer and use it in GitHub Desktop.
Vim as Golang IDE
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" 设置显示行号 | |
set number | |
" 开启语法高亮功能 | |
syntax enable | |
" 允许用指定语法高亮配色方案替换默认方案 | |
syntax on | |
" 自适应不同语言的智能缩进 | |
filetype indent on | |
" 将制表符扩展为空格 | |
set expandtab | |
" 设置编辑时制表符占用空格数 | |
set tabstop=2 | |
" 高亮显示当前行/列 | |
set cursorline | |
set cursorcolumn | |
" 高亮显示搜索结果 | |
set hlsearch | |
" 配色方案 | |
set background=dark | |
" 设置多彩配色方案 | |
" https://github.com/tomasr/molokai | |
" colorscheme wells-colors | |
colorscheme molokai | |
let g:molokai_original = 1 | |
let g:rehash256 = 1 | |
" 禁止显示滚动条 | |
set guioptions-=l | |
set guioptions-=L | |
set guioptions-=r | |
set guioptions-=R | |
" 禁止显示菜单和工具条 | |
set guioptions-=m | |
set guioptions-=T | |
"""""""""""""""""""""""" Vundle Start """""""""""""""""""""""""" | |
set nocompatible " be iMproved, required | |
filetype off " required | |
" set the runtime path to include Vundle and initialize | |
set rtp+=~/.vim/bundle/Vundle.vim | |
call vundle#begin() | |
" let Vundle manage Vundle, required | |
Plugin 'gmarik/Vundle.vim' | |
"""""""""""""""" My plugins here """""""""""""""""""""""" | |
"""""""""""" | |
" Nerdtree " | |
"""""""""""" | |
Plugin 'scrooloose/nerdtree.git' | |
" autocmd vimenter * NERDTree | |
map <F2> :NERDTreeToggle<CR> | |
autocmd StdinReadPre * let s:std_in=2 | |
autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif | |
let mapleader = ',' | |
nnoremap <leader>d :NERDTreeToggle<CR> | |
let g:vim_markdown_folding_disabled=1 | |
"""""""""""" | |
" YCM " | |
"""""""""""" | |
" Plugin 'Valloric/YouCompleteMe' | |
""""""""""" | |
" VIM-GO " | |
""""""""""" | |
Plugin 'fatih/vim-go' | |
let g:go_disable_autoinstall = 0 " 禁止自动更新 | |
let g:go_fmt_fai_silently = 0 | |
let g:go_doc_keywordprg_enabled = 0 | |
" Go keyboard mappings | |
au FileType go nmap <Leader>s <Plug>(go-implements) | |
au FileType go nmap <Leader>i <Plug>(go-info) | |
au FileType go nmap <Leader>gd <Plug>(go-doc) | |
au FileType go nmap <Leader>gv <Plug>(go-doc-vertical) | |
au FileType go nmap <Leader>gb <Plug>(go-doc-browser) | |
au FileType go nmap <leader>r <Plug>(go-run) | |
au FileType go nmap <leader>b :!go run %<CR> | |
" 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 <Leader>ds <Plug>(go-def-split) | |
au FileType go nmap <Leader>dv <Plug>(go-def-vertical) | |
au FileType go nmap <Leader>dt <Plug>(go-def-tab) | |
" Enable syntax highting on everything | |
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 | |
""""""""""" | |
"commenter" | |
""""""""""" | |
Plugin 'scrooloose/nerdcommenter' | |
"""""""""""""""""""""""" My plugins end | |
call vundle#end() " required | |
filetype plugin indent on " required | |
"""""""""""""""""""""""" Vundle End """""""""""""""""""""""""" | |
" 自动补全 neocomplete | |
" https://github.com/Shougo/neocomplete.vim | |
"Note: This option must set it in .vimrc(_vimrc). NOT IN .gvimrc(_gvimrc)! | |
let g:acp_enableAtStartup = 0 | |
" Use neocomplete. | |
let g:neocomplete#enable_at_startup = 1 | |
" Use smartcase. | |
let g:neocomplete#enable_smart_case = 1 | |
" Set minimum syntax keyword length. | |
let g:neocomplete#sources#syntax#min_keyword_length = 3 | |
let g:neocomplete#lock_buffer_name_pattern = '\*ku\*' | |
" Define dictionary. | |
let g:neocomplete#sources#dictionary#dictionaries = { | |
\ 'default' : '', | |
\ 'vimshell' : $HOME.'/.vimshell_hist', | |
\ 'scheme' : $HOME.'/.gosh_completions' | |
\ } | |
" Define keyword. | |
if !exists('g:neocomplete#keyword_patterns') | |
let g:neocomplete#keyword_patterns = {} | |
endif | |
let g:neocomplete#keyword_patterns['default'] = '\h\w*' | |
" Plugin key-mappings. | |
inoremap <expr><C-g> neocomplete#undo_completion() | |
inoremap <expr><C-l> neocomplete#complete_common_string() | |
" Recommended key-mappings. | |
" <CR>: close popup and save indent. | |
inoremap <silent> <CR> <C-r>=<SID>my_cr_function()<CR> | |
function! s:my_cr_function() | |
return neocomplete#close_popup() . "\<CR>" | |
" For no inserting <CR> key. | |
"return pumvisible() ? neocomplete#close_popup() : "\<CR>" | |
endfunction | |
" <TAB>: completion. | |
inoremap <expr><TAB> pumvisible() ? "\<C-n>" : "\<TAB>" | |
" <C-h>, <BS>: close popup and delete backword char. | |
inoremap <expr><C-h> neocomplete#smart_close_popup()."\<C-h>" | |
inoremap <expr><BS> neocomplete#smart_close_popup()."\<C-h>" | |
inoremap <expr><C-y> neocomplete#close_popup() | |
inoremap <expr><C-e> neocomplete#cancel_popup() | |
" Close popup by <Space>. | |
"inoremap <expr><Space> pumvisible() ? neocomplete#close_popup() : "\<Space>" | |
" For cursor moving in insert mode(Not recommended) | |
"inoremap <expr><Left> neocomplete#close_popup() . "\<Left>" | |
"inoremap <expr><Right> neocomplete#close_popup() . "\<Right>" | |
"inoremap <expr><Up> neocomplete#close_popup() . "\<Up>" | |
"inoremap <expr><Down> neocomplete#close_popup() . "\<Down>" | |
" Or set this. | |
"let g:neocomplete#enable_cursor_hold_i = 1 | |
" Or set this. | |
"let g:neocomplete#enable_insert_char_pre = 1 | |
" AutoComplPop like behavior. | |
"let g:neocomplete#enable_auto_select = 1 | |
" Shell like behavior(not recommended). | |
"set completeopt+=longest | |
"let g:neocomplete#enable_auto_select = 1 | |
"let g:neocomplete#disable_auto_complete = 1 | |
"inoremap <expr><TAB> pumvisible() ? "\<Down>" : "\<C-x>\<C-u>" | |
" 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:neocomplete#sources#omni#input_patterns') | |
let g:neocomplete#sources#omni#input_patterns = {} | |
endif | |
"let g:neocomplete#sources#omni#input_patterns.php = '[^. \t]->\h\w*\|\h\w*::' | |
"let g:neocomplete#sources#omni#input_patterns.c = '[^.[:digit:] *\t]\%(\.\|->\)' | |
"let g:neocomplete#sources#omni#input_patterns.cpp = '[^.[:digit:] *\t]\%(\.\|->\)\|\h\w*::' | |
" For perlomni.vim setting. | |
" https://github.com/c9s/perlomni.vim | |
" let g:neocomplete#sources#omni#input_patterns.perl = '\h\w*->\h\w*\|\h\w*::' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment