@@ -29,18 +29,7 @@ function! go#doc#OpenBrowser(...) abort
29
29
let name = out[" name" ]
30
30
let decl = out[" decl" ]
31
31
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 ()
44
33
let godoc_url .= " /" . import
45
34
if decl !~ " ^package"
46
35
let godoc_url .= " #" . name
@@ -61,7 +50,7 @@ function! go#doc#OpenBrowser(...) abort
61
50
let exported_name = pkgs[1 ]
62
51
63
52
" 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
65
54
call go#tool#OpenBrowser (godoc_url)
66
55
endfunction
67
56
@@ -225,5 +214,18 @@ function! s:godocNotFound(content) abort
225
214
return a: content = ~# ' ^.*: no such file or directory\n$'
226
215
endfunction
227
216
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
228
230
229
231
" vim: sw = 2 ts = 2 et
0 commit comments