mirror of
https://github.com/golang/go
synced 2024-11-13 15:10:22 -07:00
misc/vim: Separate package and package members.
This change allow to godoc: :Godoc github.com/mattn/go-gtk/gtk :Godoc github.com/mattn/go-gtk/gtk NewWindow :Godoc encoding/json :Godoc encoding/json Marshal R=golang-dev, dsymonds CC=golang-dev https://golang.org/cl/14171043
This commit is contained in:
parent
ac3d6a56c9
commit
fcee50c46e
@ -31,6 +31,12 @@ endif
|
|||||||
function! go#complete#Package(ArgLead, CmdLine, CursorPos)
|
function! go#complete#Package(ArgLead, CmdLine, CursorPos)
|
||||||
let dirs = []
|
let dirs = []
|
||||||
|
|
||||||
|
let words = split(a:CmdLine, '\s\+', 1)
|
||||||
|
if len(words) > 2
|
||||||
|
" TODO Complete package members
|
||||||
|
return []
|
||||||
|
endif
|
||||||
|
|
||||||
if executable('go')
|
if executable('go')
|
||||||
let goroot = substitute(system('go env GOROOT'), '\n', '', 'g')
|
let goroot = substitute(system('go env GOROOT'), '\n', '', 'g')
|
||||||
if v:shell_error
|
if v:shell_error
|
||||||
|
@ -31,7 +31,7 @@ if !exists('g:go_godoc_commands')
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
if g:go_godoc_commands
|
if g:go_godoc_commands
|
||||||
command! -nargs=* -range -complete=customlist,go#complete#Package Godoc :call s:Godoc(<q-args>)
|
command! -nargs=* -range -complete=customlist,go#complete#Package Godoc :call s:Godoc(<f-args>)
|
||||||
endif
|
endif
|
||||||
|
|
||||||
nnoremap <silent> <Plug>(godoc-keyword) :<C-u>call <SID>Godoc('')<CR>
|
nnoremap <silent> <Plug>(godoc-keyword) :<C-u>call <SID>Godoc('')<CR>
|
||||||
@ -71,7 +71,7 @@ function! s:GodocWord(word)
|
|||||||
echo "godoc command not found."
|
echo "godoc command not found."
|
||||||
echo " install with: go get code.google.com/p/go.tools/cmd/godoc"
|
echo " install with: go get code.google.com/p/go.tools/cmd/godoc"
|
||||||
echohl None
|
echohl None
|
||||||
return
|
return 0
|
||||||
endif
|
endif
|
||||||
let word = a:word
|
let word = a:word
|
||||||
silent! let content = system('godoc ' . word)
|
silent! let content = system('godoc ' . word)
|
||||||
@ -80,12 +80,12 @@ function! s:GodocWord(word)
|
|||||||
silent! let content = system('godoc ' . s:last_word.'/'.word)
|
silent! let content = system('godoc ' . s:last_word.'/'.word)
|
||||||
if v:shell_error || !len(content)
|
if v:shell_error || !len(content)
|
||||||
echo 'No documentation found for "' . word . '".'
|
echo 'No documentation found for "' . word . '".'
|
||||||
return
|
return 0
|
||||||
endif
|
endif
|
||||||
let word = s:last_word.'/'.word
|
let word = s:last_word.'/'.word
|
||||||
else
|
else
|
||||||
echo 'No documentation found for "' . word . '".'
|
echo 'No documentation found for "' . word . '".'
|
||||||
return
|
return 0
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
let s:last_word = word
|
let s:last_word = word
|
||||||
@ -96,30 +96,34 @@ function! s:GodocWord(word)
|
|||||||
silent! normal gg
|
silent! normal gg
|
||||||
setlocal nomodifiable
|
setlocal nomodifiable
|
||||||
setfiletype godoc
|
setfiletype godoc
|
||||||
|
return 1
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:Godoc(...)
|
function! s:Godoc(...)
|
||||||
let word = join(a:000, ' ')
|
if !len(a:000)
|
||||||
if !len(word)
|
|
||||||
let oldiskeyword = &iskeyword
|
let oldiskeyword = &iskeyword
|
||||||
setlocal iskeyword+=.
|
setlocal iskeyword+=.
|
||||||
let word = expand('<cword>')
|
let word = expand('<cword>')
|
||||||
let &iskeyword = oldiskeyword
|
let &iskeyword = oldiskeyword
|
||||||
|
let word = substitute(word, '[^a-zA-Z0-9\\/._~-]', '', 'g')
|
||||||
|
let words = split(word, '\.\ze[^./]\+$')
|
||||||
|
else
|
||||||
|
let words = a:000
|
||||||
endif
|
endif
|
||||||
let word = substitute(word, '[^a-zA-Z0-9\\/._~-]', '', 'g')
|
|
||||||
let words = split(word, '\.')
|
|
||||||
if !len(words)
|
if !len(words)
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
call s:GodocWord(words[0])
|
if s:GodocWord(words[0])
|
||||||
if len(words) > 1
|
if len(words) > 1
|
||||||
if search('^\%(const\|var\|type\|\s\+\) ' . words[1] . '\s\+=\s')
|
if search('^\%(const\|var\|type\|\s\+\) ' . words[1] . '\s\+=\s')
|
||||||
return
|
return
|
||||||
|
endif
|
||||||
|
if search('^func ' . words[1] . '(')
|
||||||
|
silent! normal zt
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
echo 'No documentation found for "' . words[1] . '".'
|
||||||
endif
|
endif
|
||||||
if search('^func ' . words[1] . '(')
|
|
||||||
return
|
|
||||||
endif
|
|
||||||
echo 'No documentation found for "' . word . '".'
|
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user