neovim / pynvim

Python client and plugin host for Nvim
http://pynvim.readthedocs.io/en/latest/
Apache License 2.0
1.53k stars 119 forks source link

hit-enter prompt with vim.err_write with redraw before last line (deoplete) #327

Open blueyed opened 6 years ago

blueyed commented 6 years ago

The following will not trigger a hit-enter prompt:

:py3 import vim; vim.err_write('\n'.join(str(x) for x in range(10))+'\n'); vim.command('redraw'); vim.err_write('last\n')

It displays the lines 0-9, then waits for a short time, and displays "last". This is good/useful when wanting to add a traceback/more info for :messages, but have the actual error in the end (without a large red blob).

But for some reason similar code in deoplete will not (when adding a redraw command before the last line) - it displays all of it at once, causing a hit-enter prompt: https://github.com/Shougo/deoplete.nvim/blob/57d3f0c3cdfcfc1d91901a6d59d08f9008abd166/rplugin/python3/deoplete/util.py#L94-L101

This might be related to how deoplete integrates with neovim-python-client (https://github.com/Shougo/deoplete.nvim/blob/master/rplugin/python3/deoplete/parent.py#L96-L102).

justinmk commented 6 years ago

I'm not sure why the first case "waits". That seems like an accident, doesn't it?

blueyed commented 6 years ago

Agreed. I've thought that it might be intentional, but I also think that it should not wait. The main issue is that the second case even triggers the hit-enter prompt though.

justinmk commented 6 years ago

I don't understand why it's a problem for an error message to trigger hit-enter? Isn't that normal?

blueyed commented 6 years ago

The trick that deoplete uses is to first use echom for additional info (traceback), then redraw and then echom for the main msg. This way you have it in :messages, but are not bothered with the full blob initially. I've noticed that this does not work as expected when using vim.err_write.

justinmk commented 6 years ago

Try nvim_call_atomic or server-side VimL/Lua ?

blueyed commented 6 years ago

@justinmk Please elaborate. Do you mean to do this from deoplete's error_tb (Python)? (https://github.com/Shougo/deoplete.nvim/blob/57d3f0c3cdfcfc1d91901a6d59d08f9008abd166/rplugin/python3/deoplete/util.py#L94-L101) deoplete uses rpcnotify to trigger the Python code.