aboutsummaryrefslogtreecommitdiffstats
path: root/ftplugin/go.vim
diff options
context:
space:
mode:
authorTeddy Wing2022-05-05 20:41:01 +0200
committerTeddy Wing2022-05-05 20:48:35 +0200
commit3ae7a9a9454577ba1dc2f774a2ca7feb90834780 (patch)
tree80b451da46ea645b2c21670b923e73fb6e047562 /ftplugin/go.vim
parentd9ad91b54971581e4d6c55fc9bd94ef2896c8a3a (diff)
downloaddotvim-3ae7a9a9454577ba1dc2f774a2ca7feb90834780.tar.bz2
ftplugin/go.vim: Allow `:GoDoc` to work with `<cword>`
This re-enables `K` keyworkprg functionality for the `GoDoc` command, this time using my custom version.
Diffstat (limited to 'ftplugin/go.vim')
-rw-r--r--ftplugin/go.vim23
1 files changed, 18 insertions, 5 deletions
diff --git a/ftplugin/go.vim b/ftplugin/go.vim
index d22bb67..4fb59ea 100644
--- a/ftplugin/go.vim
+++ b/ftplugin/go.vim
@@ -46,8 +46,21 @@ nmap <buffer> <C-w>z<C-^> :call go#alternate#Switch(1, 'vsplit')<CR>
nmap <buffer> Ze <Plug>(go-iferr)
-" TODO: if no q-args, use cword
-command! -buffer -nargs=1 GoDoc :new <Bar>
- \ execute 'read !go doc -all ' . shellescape(<q-args>) <Bar>
- \ set readonly nomodified <Bar>
- \ setfiletype go
+command! -buffer -nargs=? GoDoc call s:GoDoc(<q-args>)
+
+
+if exists('*s:GoDoc')
+ finish
+endif
+
+function! s:GoDoc(search_term)
+ let search_term = a:search_term
+ if search_term == ''
+ let search_term = expand('<cword>')
+ endif
+
+ new
+ \| execute 'read !go doc -all ' . shellescape(search_term)
+ \| set readonly nomodified
+ \| setfiletype go
+endfunction