-
-
Notifications
You must be signed in to change notification settings - Fork 767
Expand file tree
/
Copy pathdoc.vim
More file actions
40 lines (34 loc) · 1.01 KB
/
doc.vim
File metadata and controls
40 lines (34 loc) · 1.01 KB
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
35
36
37
38
39
40
" 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
if g:pymode_doc_vertical
wincmd L
endif
normal gg
wincmd p
endfunction "}}}