Skip to content

Instantly share code, notes, and snippets.

@dgryski
Last active December 14, 2015 22:09
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dgryski/5156158 to your computer and use it in GitHub Desktop.
Save dgryski/5156158 to your computer and use it in GitHub Desktop.
vim plugin for godef
" needs https://code.google.com/p/rog-go/source/browse/exp/cmd/godef/godef.go
if !exists("g:godef_command")
let g:godef_command = "godef"
endif
function! GodefUnderCursor()
let offs=line2byte(line('.'))+col('.')-1
call Godef("-o=" . offs)
endfunction
function! Godef(arg)
let out=system(g:godef_command . " -f=" . bufname("%") . " " . a:arg)
if out =~ 'godef: '
let out=substitute(out, '\n$', '', '')
echom out
else
split
lexpr out
end
endfunction
nnoremap <buffer> gd :call GodefUnderCursor()<cr>
command! -range -nargs=1 Godef :call Godef(<q-args>)
@dgryski
Copy link
Author

dgryski commented Mar 15, 2013

I've moved this to my actual github page: https://github.com/dgryski/vim-godef/

New development, if any, will happen there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment