]> Cypherpunks repositories - gostls13.git/commitdiff
misc/vim: make Godoc command work with "log.Print".
authorYasuhiro Matsumoto <mattn.jp@gmail.com>
Tue, 26 Mar 2013 06:39:46 +0000 (17:39 +1100)
committerDavid Symonds <dsymonds@golang.org>
Tue, 26 Mar 2013 06:39:46 +0000 (17:39 +1100)
R=dsymonds
CC=golang-dev
https://golang.org/cl/7757043

misc/vim/plugin/godoc.vim

index a9abb7ae6cab51ce6f306bc293b8b79fcd296af8..a7b84de747073c76fd3a25b836dedbde354bd93c 100644 (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>)