File tree Expand file tree Collapse file tree 3 files changed +30
-8
lines changed
Expand file tree Collapse file tree 3 files changed +30
-8
lines changed Original file line number Diff line number Diff line change 22"
33PymodePython import pymode
44
5+
6+ fun ! pymode#doc#find () " {{{
7+ " Extract the 'word' at the cursor, expanding leftwards across identifiers
8+ " and the . operator, and rightwards across the identifier only.
9+ "
10+ " For example:
11+ " import xml.dom.minidom
12+ " ^ !
13+ "
14+ " With the cursor at ^ this returns 'xml'; at ! it returns 'xml.dom'.
15+ let l: line = getline (" ." )
16+ let l: pre = l: line [: col (" ." ) - 1 ]
17+ let l: suf = l: line [col (" ." ):]
18+ let word = matchstr (pre , " [A-Za-z0-9_.]*$" ) . matchstr (suf, " ^[A-Za-z0-9_]*" )
19+ call pymode#doc#show (word)
20+ endfunction " }}}
21+
22+
23+
524fun ! pymode#doc#show (word) " {{{
625 if a: word == ' '
726 call pymode#error (" No name/symbol under cursor!" )
8- else
9- call pymode#tempbuffer_open (' __doc__' )
10- PymodePython pymode.get_documentation ()
11- setlocal nomodifiable
12- setlocal nomodified
13- setlocal filetype = rst
14- wincmd p
27+ return 0
1528 endif
29+
30+ call pymode#tempbuffer_open (' __doc__' )
31+ PymodePython pymode.get_documentation ()
32+ setlocal nomodifiable
33+ setlocal nomodified
34+ setlocal filetype = rst
35+ wincmd p
36+
1637endfunction " }}}
1738
Original file line number Diff line number Diff line change @@ -100,7 +100,7 @@ if g:pymode_doc
100100 command ! - buffer -nargs =1 PymodeDoc call pymode#doc#show (" <args>" )
101101
102102 " Set keys
103- exe " nnoremap <silent> <buffer> " g: pymode_doc_bind " :call pymode#doc#show(expand('<cword>') )<CR>"
103+ exe " nnoremap <silent> <buffer> " g: pymode_doc_bind " :call pymode#doc#find( )<CR>"
104104 exe " vnoremap <silent> <buffer> " g: pymode_doc_bind " :<C-U>call pymode#doc#show(@*)<CR>"
105105
106106end
Original file line number Diff line number Diff line change @@ -35,3 +35,4 @@ def get_documentation():
3535 help (vim .eval ('a:word' ))
3636 sys .stdout , out = _ , sys .stdout .getvalue ()
3737 vim .current .buffer .append (str (out ).splitlines (), 0 )
38+
You can’t perform that action at this time.
0 commit comments