forked from python-mode/python-mode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdoc.vim
More file actions
34 lines (30 loc) · 967 Bytes
/
doc.vim
File metadata and controls
34 lines (30 loc) · 967 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
" Python-mode search by documentation
"
PymodePython import pymode
fun! pymode#doc#find() "{{{
" Extract the 'word' at the cursor, expanding leftwards across identifiers
" and the . operator, and rightwards across the identifier only.
"
" For example:
" import xml.dom.minidom
" ^ !
"
" With the cursor at ^ this returns 'xml'; at ! it returns 'xml.dom'.
let l:line = getline(".")
let l:pre = l:line[:col(".") - 1]
let l:suf = l:line[col("."):]
let word = matchstr(pre, "[A-Za-z0-9_.]*$") . matchstr(suf, "^[A-Za-z0-9_]*")
call pymode#doc#show(word)
endfunction "}}}
fun! pymode#doc#show(word) "{{{
if a:word == ''
call pymode#error("No name/symbol under cursor!")
return 0
endif
call pymode#tempbuffer_open('__doc__')
PymodePython pymode.get_documentation()
setlocal nomodifiable
setlocal nomodified
setlocal filetype=rst
wincmd p
endfunction "}}}