From 3ae7a9a9454577ba1dc2f774a2ca7feb90834780 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Thu, 5 May 2022 20:41:01 +0200 Subject: ftplugin/go.vim: Allow `:GoDoc` to work with `` This re-enables `K` keyworkprg functionality for the `GoDoc` command, this time using my custom version. --- ftplugin/go.vim | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'ftplugin') 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 z :call go#alternate#Switch(1, 'vsplit') nmap Ze (go-iferr) -" TODO: if no q-args, use cword -command! -buffer -nargs=1 GoDoc :new - \ execute 'read !go doc -all ' . shellescape() - \ set readonly nomodified - \ setfiletype go +command! -buffer -nargs=? GoDoc call s:GoDoc() + + +if exists('*s:GoDoc') + finish +endif + +function! s:GoDoc(search_term) + let search_term = a:search_term + if search_term == '' + let search_term = expand('') + endif + + new + \| execute 'read !go doc -all ' . shellescape(search_term) + \| set readonly nomodified + \| setfiletype go +endfunction -- cgit v1.2.3