neovim / pynvim

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

Startup script for Ipython #391

Open mrsalo opened 5 years ago

mrsalo commented 5 years ago

In order to use and test out pynvim it would be beneficial to have a startup script for IPython that populates a connection to a local NeoVim instance without further setup required. At least in Arch Linux AFAIK every NeoVim instance populates its API endpoint under /tmp/nvimRANDOM/0. This makes it possible to connect to every instance, echo a identifying message to the user to enable him/her choosing to which instance to connect to. If there is only one instance it is also possible to connect to it directly. I created a small script that implements the above mentioned behviour. Is this interesting to anyone else? Example: Peek 2019-05-02 22-06

justinmk commented 5 years ago

Sure. Here's something similar in my config: https://github.com/justinmk/config/blob/ad5b792049b352274d4cbd3525a2aff6ce296a7e/.config/nvim/init.vim#L1339-L1361

I think it might be a good idea to have some sort of convention where each client implements something like this. Then the user can just rpcrequest({chan}, 'repl').

Or it could simply be a plugin included with Nvim core runtime.

mrsalo commented 5 years ago

I thought about staying completely in neovim by starting Ipython in conjunction with :terminal similar as you did in your init.vim, too. The only problem is that i cannot use the convenient nvim.current .buffer anymore as i am referring to the :terminal buffer then. That's why I chose to start IPython in another terminal. I think I do not fully understand your rpcrequest({chan}, 'repl') suggestion, could you elaborate on this?