Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow auto features to be disabled without restarting Vim #939

Merged
merged 1 commit into from
Jul 17, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 37 additions & 17 deletions plugin/go.vim
Original file line number Diff line number Diff line change
Expand Up @@ -143,44 +143,64 @@ function! s:echo_go_info()
redraws! | echo "vim-go: " | echohl Function | echon item.info | echohl None
endfunction

augroup vim-go
autocmd!

" GoInfo automatic update
if get(g:, "go_auto_type_info", 0)
autocmd CursorHold *.go nested call go#complete#Info(1)
endif

function! s:auto_sameids()
" GoSameId automatic update
if get(g:, "go_auto_sameids", 0)
autocmd CursorMoved *.go nested call go#guru#SameIds(-1)
call go#guru#SameIds(-1)
endif
endfunction

" Echo the identifier information when completion is done. Useful to see
" the signature of a function, etc...
if exists('##CompleteDone')
autocmd CompleteDone *.go nested call s:echo_go_info()
function! s:auto_type_info()
" GoInfo automatic update
if get(g:, "go_auto_type_info", 0)
call go#complete#Info(1)
endif
endfunction

function! s:fmt_autosave()
" Go code formatting on save
if get(g:, "go_fmt_autosave", 1)
autocmd BufWritePre *.go call go#fmt#Format(-1)
call go#fmt#Format(-1)
endif
endfunction

function! s:asmfmt_autosave()
" Go asm formatting on save
if get(g:, "go_asmfmt_autosave", 1)
autocmd BufWritePre *.s call go#asmfmt#Format()
call go#asmfmt#Format()
endif
endfunction

function! s:metalinter_autosave()
" run gometalinter on save
if get(g:, "go_metalinter_autosave", 0)
autocmd BufWritePost *.go call go#lint#Gometa(1)
call go#lint#Gometa(1)
endif
endfunction

function! s:template_autocreate()
" create new template from scratch
if get(g:, "go_template_autocreate", 1)
autocmd BufNewFile *.go call go#template#create()
call go#template#create()
endif
endfunction

augroup vim-go
autocmd!

autocmd CursorHold *.go call s:auto_type_info()
autocmd CursorMoved *.go call s:auto_sameids()

" Echo the identifier information when completion is done. Useful to see
" the signature of a function, etc...
if exists('##CompleteDone')
autocmd CompleteDone *.go call s:echo_go_info()
endif

autocmd BufWritePre *.go call s:fmt_autosave()
autocmd BufWritePre *.s call s:asmfmt_autosave()
autocmd BufWritePost *.go call s:metalinter_autosave()
autocmd BufNewFile *.go call s:template_autocreate()
augroup END

" vim: sw=2 ts=2 et