misc/vim: make Godoc command work with "log.Print".

R=dsymonds
CC=golang-dev
https://golang.org/cl/7757043
This commit is contained in:
Yasuhiro Matsumoto 2013-03-26 17:39:46 +11:00 committed by David Symonds
parent adb9d60cd1
commit d7434816c1
1 changed files with 15 additions and 2 deletions

View File

@ -70,13 +70,26 @@ endfunction
function! s:Godoc(...)
let word = join(a:000, ' ')
if !len(word)
let oldiskeyword = &iskeyword
setlocal iskeyword+=.
let word = expand('<cword>')
let &iskeyword = oldiskeyword
endif
let word = substitute(word, '[^a-zA-Z0-9\\/._~-]', '', 'g')
if !len(word)
let words = split(word, '\.')
if !len(words)
return
endif
call s:GodocWord(word)
call s:GodocWord(words[0])
if len(words) > 1
if search('^\%(const\|var\|type\|\s\+\) ' . words[1] . '\s\+=\s')
return
endif
if search('^func ' . words[1] . '(')
return
endif
echo 'No documentation found for "' . word . '".'
endif
endfunction
command! -nargs=* -range -complete=customlist,go#complete#Package Godoc :call s:Godoc(<q-args>)