Skip to content

Commit b68d13b

Browse files
authored
Merge pull request #1629 from stamblerre/master
add additional godoc url configuration
2 parents bb99031 + 8a45bec commit b68d13b

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

autoload/go/doc.vim

+15-13
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,7 @@ function! go#doc#OpenBrowser(...) abort
2929
let name = out["name"]
3030
let decl = out["decl"]
3131

32-
let godoc_url = get(g:, 'go_doc_url', 'https://godoc.org')
33-
if godoc_url isnot 'https://godoc.org'
34-
" strip last '/' character if available
35-
let last_char = strlen(godoc_url) - 1
36-
if godoc_url[last_char] == '/'
37-
let godoc_url = strpart(godoc_url, 0, last_char)
38-
endif
39-
40-
" custom godoc installations expects it
41-
let godoc_url .= "/pkg"
42-
endif
43-
32+
let godoc_url = s:customGodocUrl()
4433
let godoc_url .= "/" . import
4534
if decl !~ "^package"
4635
let godoc_url .= "#" . name
@@ -61,7 +50,7 @@ function! go#doc#OpenBrowser(...) abort
6150
let exported_name = pkgs[1]
6251

6352
" example url: https://godoc.org/github.com/fatih/set#Set
64-
let godoc_url = "https://godoc.org/" . pkg . "#" . exported_name
53+
let godoc_url = s:customGodocUrl() . "/" . pkg . "#" . exported_name
6554
call go#tool#OpenBrowser(godoc_url)
6655
endfunction
6756

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

217+
function! s:customGodocUrl() abort
218+
let godoc_url = get(g:, 'go_doc_url', 'https://godoc.org')
219+
if godoc_url isnot 'https://godoc.org'
220+
" strip last '/' character if available
221+
let last_char = strlen(godoc_url) - 1
222+
if godoc_url[last_char] == '/'
223+
let godoc_url = strpart(godoc_url, 0, last_char)
224+
endif
225+
" custom godoc installations expect /pkg before package names
226+
let godoc_url .= "/pkg"
227+
endif
228+
return godoc_url
229+
endfunction
228230

229231
" vim: sw=2 ts=2 et

0 commit comments

Comments
 (0)