Skip to content

Commit

Permalink
Merge pull request #894 from mattn/godoc
Browse files Browse the repository at this point in the history
open GodocView if argument is provided for :GoDoc
  • Loading branch information
fatih authored Jun 11, 2016
2 parents 6a0c880 + cf4f0ea commit 8d73ed0
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions autoload/go/doc.vim
Original file line number Diff line number Diff line change
Expand Up @@ -77,17 +77,27 @@ function! go#doc#OpenBrowser(...)
endfunction

function! go#doc#Open(newmode, mode, ...)
" check if we have 'gogetdoc' and use it automatically
let bin_path = go#path#CheckBinPath('gogetdoc')
if empty(bin_path)
return
endif
if len(a:000)
" check if we have 'godoc' and use it automatically
let bin_path = go#path#CheckBinPath('godoc')
if empty(bin_path)
return
endif

let command = printf("%s %s", bin_path, join(a:000, ' '))
else
" check if we have 'gogetdoc' and use it automatically
let bin_path = go#path#CheckBinPath('gogetdoc')
if empty(bin_path)
return
endif

let offset = go#util#OffsetCursor()
let fname = expand("%:p")
let pos = shellescape(fname.':#'.offset)
let offset = go#util#OffsetCursor()
let fname = expand("%:p:gs!\\!/!")
let pos = shellescape(fname.':#'.offset)

let command = printf("%s -pos %s", bin_path, pos)
let command = printf("%s -pos %s", bin_path, pos)
endif

let out = go#util#System(command)
if go#util#ShellError() != 0
Expand Down Expand Up @@ -135,6 +145,7 @@ function! s:GodocView(newposition, position, content)
call append(0, split(a:content, "\n"))
sil $delete _
setlocal nomodifiable
sil normal! gg

" close easily with <esc> or enter
noremap <buffer> <silent> <CR> :<C-U>close<CR>
Expand Down

0 comments on commit 8d73ed0

Please sign in to comment.