Skip to content

Commit

Permalink
Merge pull request #1629 from stamblerre/master
Browse files Browse the repository at this point in the history
add additional godoc url configuration
  • Loading branch information
fatih authored Jan 2, 2018
2 parents bb99031 + 8a45bec commit b68d13b
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions autoload/go/doc.vim
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,7 @@ function! go#doc#OpenBrowser(...) abort
let name = out["name"]
let decl = out["decl"]

let godoc_url = get(g:, 'go_doc_url', 'https://godoc.org')
if godoc_url isnot 'https://godoc.org'
" strip last '/' character if available
let last_char = strlen(godoc_url) - 1
if godoc_url[last_char] == '/'
let godoc_url = strpart(godoc_url, 0, last_char)
endif

" custom godoc installations expects it
let godoc_url .= "/pkg"
endif

let godoc_url = s:customGodocUrl()
let godoc_url .= "/" . import
if decl !~ "^package"
let godoc_url .= "#" . name
Expand All @@ -61,7 +50,7 @@ function! go#doc#OpenBrowser(...) abort
let exported_name = pkgs[1]

" example url: https://godoc.org/github.com/fatih/set#Set
let godoc_url = "https://godoc.org/" . pkg . "#" . exported_name
let godoc_url = s:customGodocUrl() . "/" . pkg . "#" . exported_name
call go#tool#OpenBrowser(godoc_url)
endfunction

Expand Down Expand Up @@ -225,5 +214,18 @@ function! s:godocNotFound(content) abort
return a:content =~# '^.*: no such file or directory\n$'
endfunction

function! s:customGodocUrl() abort
let godoc_url = get(g:, 'go_doc_url', 'https://godoc.org')
if godoc_url isnot 'https://godoc.org'
" strip last '/' character if available
let last_char = strlen(godoc_url) - 1
if godoc_url[last_char] == '/'
let godoc_url = strpart(godoc_url, 0, last_char)
endif
" custom godoc installations expect /pkg before package names
let godoc_url .= "/pkg"
endif
return godoc_url
endfunction

" vim: sw=2 ts=2 et

0 comments on commit b68d13b

Please sign in to comment.