Skip to content

Commit

Permalink
cmd/govim: only doautoall on govim events (#871)
Browse files Browse the repository at this point in the history
This means we don't unnecessarily trigger other autocommands for a
situation where we only need to trigger govim events once the plugin has
loaded.
  • Loading branch information
myitcv committed May 11, 2020
1 parent 6b50ea7 commit 8dbe91b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 21 deletions.
36 changes: 17 additions & 19 deletions ftplugin/go.vim
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
if GOVIMPluginStatus() == "initcomplete"
" Hover
setlocal balloonexpr=GOVIM_internal_BalloonExpr()
" Hover
setlocal balloonexpr=GOVIM_internal_BalloonExpr()

" Completion
setlocal omnifunc=GOVIM_internal_Complete
" Completion
setlocal omnifunc=GOVIM_internal_Complete

" go-to-def
nnoremap <buffer> <silent> gd :GOVIMGoToDef<cr>
nnoremap <buffer> <silent> <C-]> :GOVIMGoToDef<cr>
nnoremap <buffer> <silent> <C-LeftMouse> <LeftMouse>:GOVIMGoToDef<cr>
nnoremap <buffer> <silent> g<LeftMouse> <LeftMouse>:GOVIMGoToDef<cr>
nnoremap <buffer> <silent> <C-t> :GOVIMGoToPrevDef<cr>
nnoremap <buffer> <silent> <C-RightMouse> :GOVIMGoToPrevDef<cr>
nnoremap <buffer> <silent> g<RightMouse> :GOVIMGoToPrevDef<cr>
" go-to-def
nnoremap <buffer> <silent> gd :GOVIMGoToDef<cr>
nnoremap <buffer> <silent> <C-]> :GOVIMGoToDef<cr>
nnoremap <buffer> <silent> <C-LeftMouse> <LeftMouse>:GOVIMGoToDef<cr>
nnoremap <buffer> <silent> g<LeftMouse> <LeftMouse>:GOVIMGoToDef<cr>
nnoremap <buffer> <silent> <C-t> :GOVIMGoToPrevDef<cr>
nnoremap <buffer> <silent> <C-RightMouse> :GOVIMGoToPrevDef<cr>
nnoremap <buffer> <silent> g<RightMouse> :GOVIMGoToPrevDef<cr>
" Motions
nnoremap <buffer> <silent> [[ :call GOVIMMotion("prev", "File.Decls.Pos()")<cr>
nnoremap <buffer> <silent> [] :call GOVIMMotion("prev", "File.Decls.End()")<cr>
nnoremap <buffer> <silent> ][ :call GOVIMMotion("next", "File.Decls.Pos()")<cr>
nnoremap <buffer> <silent> ]] :call GOVIMMotion("next", "File.Decls.End()")<cr>
endif
" Motions
nnoremap <buffer> <silent> [[ :call GOVIMMotion("prev", "File.Decls.Pos()")<cr>
nnoremap <buffer> <silent> [] :call GOVIMMotion("prev", "File.Decls.End()")<cr>
nnoremap <buffer> <silent> ][ :call GOVIMMotion("next", "File.Decls.Pos()")<cr>
nnoremap <buffer> <silent> ]] :call GOVIMMotion("next", "File.Decls.End()")<cr>
4 changes: 2 additions & 2 deletions plugin/govim.vim
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,8 @@ function s:define(channel, msg)
elseif a:msg[1] == "initcomplete"
let s:govim_status = "initcomplete"
" doautoall BufRead also triggers ftplugin stuff
doautoall BufRead
doautoall FileType
doautoall govim BufRead
doautoall govim FileType
if $GOVIM_DISABLE_USER_BUSY != "true"
au govim CursorMoved,CursorMovedI * ++nested :call s:userBusy(1)
au govim CursorHold,CursorHoldI * ++nested :call s:userBusy(0)
Expand Down

0 comments on commit 8dbe91b

Please sign in to comment.