Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign uppydoc support popup or float window? #1088
Comments
|
In the mean time I am using this hack: autocmd FileType python nnoremap <buffer> K :call PyDocVim()<CR>
function! PyDocVim()
python3 << EOF
import jedi
curfile = vim.current.buffer.name
row = vim.current.window.cursor[0]
col= vim.current.window.cursor[1]
script = jedi.Script(
source=None,
path=curfile,
line=row,
column=col)
try:
definitions = script.goto_definitions()
except Exception:
# print to stdout, will be in :messages
definitions = []
print("Exception, this shouldn't happen.")
print(traceback.format_exc())
if not definitions:
echo_highlight("No documentation found for that.")
vim.command("return")
docs = []
for d in definitions:
doc = d.docstring()
if doc:
title = "Docstring for %s" % d.desc_with_module
underline = "=" * len(title)
docs.append("%s\n%s\n%s" % (title, underline, doc))
else:
docs.append("|No Docstring for %s|" % d)
text = ("\n" + "-" * 79 + "\n").join(docs)
vim.command("let docWidth = %s" % len(title))
vim.command("let doc_lines = %s" % len(text.split("\n")))
EOF
"Scroll
function! s:popup_filter(winid, key)
if a:key ==# "\<c-k>"
call win_execute(a:winid, "normal! \<c-y>")
return v:true
elseif a:key ==# "\<c-j>"
call win_execute(a:winid, "normal! \<c-e>")
return v:true
elseif a:key ==# 'q' || a:key ==# 'x'
return popup_filter_menu(a:winid, 'x')
endif
return v:false
endfunction
let lines = py3eval('text')
let winid = popup_create(lines->split('\n'), #{
\ filter: function('s:popup_filter'),
\ pos: 'botleft',
\ line: 'cursor-1',
\ col: 'cursor',
\ moved: 'any',
\ border: [1,1,1,1,1,1,1,1],
\ borderchars: ['─', '│', '─', '│', '┌', '┐', '┘', '└'],
\ borderhighlight: ['Todo'],
\ padding: [0,1,0,1],
\ firstline: 1,
\ scrollbar: 1,
\ minwidth: docWidth,
\ maxwidth: 74,
\ minheight: doc_lines,
\ maxheight: 20,
\ mapping: 0,
\ })
call setbufvar(winbufnr(winid), '&syntax','rst')
call setwinvar(winid, '&wincolor', 'Normal')
endfunction |
|
looks so cooool!
it looks like related to jedi. OS: Gentoo Linux 5.4 |
|
What does your code look like? does it work on other words? |
|
You could try updating jedi, why is vim calling pynvim? Are you using Neovim(I don't expect the hack to work there) |
|
To be honest, I don't know exactly what I did in my personal setup but I do have floating documentation for python codes... not sure if provided by python-mode or some mix of python-mode with other plugins though. My vim setup is here, and I haven't added any special "patch". But again, I don't know which plugin is exactly providing that... |
Oh. Yes, indeed I am using NeoVim. |
Do you use vim or nvim? |
Looks like YCM |
vim
Hum.... good catch, could be indeed. |
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |



thanks!