Giter Site home page Giter Site logo

nvim-ipy's Introduction

nvim-ipy

This is a Jupyter front-end for Neovim, partially based on ivanov/vim-ipython, but refactored for nvim's plugin architechture and improved async event handling. Jupyter 4.x or later is required. It uses python3 per default; see below for notes on using python2. It has full support for non-python kernels.

It doesn't have all features of vim-ipython, but it has better support for long-running commands that continously produce output, for instance this silly example:

from time import sleep
for i in range(10):
    sleep(0.5)
    print(i)

Connecting/starting kernel

:IPython <args> is interpreted just like the command line jupyter console <args>, for instance:

Action command
Start new python kernel :IPython
:IPython2 (for python2 kernel)
Connect to existing kernel :IPython --existing
Start kernel in different language :IPython --kernel julia-0.6

This plugin runs in the python3 host by default, but the kernel process don't need to be the same version of python as the plugin runs in. Kernelspec can be used to launch a python2 kernel, the same way as from the Jupyter console and notebook. Use :IPython --kernel python2 or the :IPython2 shortcut. You might need to execute

ipython2 kernelspec install-self --user

on beforehand for this to work. I have tested that this plugin also supports IJulia and IHaskell, but ideally it should work with any Jupyter kernel.

If you only have the python2 host installed, you could do cd rplugin; ln -s python3 python to run this plugin in the python2 host instead.

:IPython can be invoked multiple times in the same nvim session. The old kernel connection is then closed and forgotten.

New: --no-window can be passed an argument to :IPython to hide the output window.

Keybindings

When kernel is running, following bindings can be used:

Generic default Action
<Plug>(IPy-Run) <F5> Excecute current line or visual selection
<Plug>(IPy-RunCell) Excecute current cell (see below)
<Plug>(IPy-RunAll) Excecute all lines in buffer
<Plug>(IPy-RunOp) Operator: execute over a movement or text object
<Plug>(IPy-Complete) <C-F> (insert mode) Kernel code completion
<Plug>(IPy-WordObjInfo) <leader>? Inspect variable under the cursor
<Plug>(IPy-Interrupt) <F8> Send interrupt to kernel
<Plug>(IPy-Terminate) Terminate kernel

But... The default bindings suck!

Yes, they exist mainly to quickly test this plugin. Add

let g:nvim_ipy_perform_mappings = 0

To your nvimrc and map to the generic bindings. For instance:

map <silent> <c-s> <Plug>(IPy-Run)

Cells

As a convenience, the plugin includes a definition of code cells (running only for now, later I might make them text objects). The cell is defined by setting g:ipy_celldef a list of two of rexexes that should match the beginning and end of a cell respecively. If a string is supplied, it will be used for both, and in addition the beginning and the end of the buffer will implicitly work as cells. The default is equivalent to:

let g:ipy_celldef = '^##'

To enable to define cells in a filetype, b:ipy_celldef will override the global value. As an example, add this to vimrc to support R notebooks (.rmd):

au FileType rmd let b:ipy_celldef = ['^```{r}$', '^```$']

You also need to map some key to IPy-RunCell:

map <silent> <leader>c <Plug>(IPy-RunCell)

Options

NB: the option system will soon be rewritten to allow changing options while the plugin is running, but for now you can set:

Option default Action
g:ipy_set_ft 0 (false) set filetype of output buffer to kernel language
g:ipy_highlight 1 (true) add highlights for ANSI sequences in the output
g:ipy_truncate_input 0 when > 0, don't echo inputs larger than this number of lines
g:ipy_shortprompt 0 (false) use shorter prompts (TODO: let user set arbitrary format)
g:ipy_celldef '^##' definition of a code cell, see above

Note that the filetype syntax highlight could interact badly with the highlights sent from the kernel as ANSI sequences (in IPython tracebacks, for instance). Therefore both are not enabled by default. I might look into a better solution for this.

Exported vimscript functions

Most useful is IPyRun("string of code"[, silent]) which can be called to programmatically execute any code. The optional silent will avoid printing code and result to the console if nonzero. This is useful to bind common commands to a key. This will close all figures in matplotlib:

nnoremap <Leader>c :call IPyRun('close("all")',1)<cr>

IPyConnect(args...) can likewise be used to connect with vimscript generated arguments.

IPyOmniFunc can be used as &completefunc/&omnifunc for use with a completer framework. Note that unlike <Plug>(IPy-Complete) this is synchronous and waits for the kernel, so if the kernel hangs this will hang nvim! For use with async completion like Deoplete it would be better to create a dedicated source.

nvim-ipy's People

Contributors

bfredl avatar dziwoki avatar johnreid avatar naquad avatar phi-mah avatar zchee avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nvim-ipy's Issues

Better interface to IPyRun

Hi,

I have been using vim-ipython-cell to interface with ipython. Recently, my workflow included driving qtconsole from vim and discovered this plugin after trying a few alternatives. I love this plugin and it has been working to work with. But I miss the navigation features of vim-ipython-cell which drives ipython through vim-slime. I am trying to get it to talk to nvim-ipy instead to drive jupyter console instead.

I was able to get most of the functionality by making a few likes of change to both nvim-ipy and vim-ipython-cell. The main change to nvim-ipy was to create a better interface to IPyRun by adding the following:

diff --git i/plugin/ipy.vim w/plugin/ipy.vim
index 4a16464..9cbdb4b 100644
--- i/plugin/ipy.vim
+++ w/plugin/ipy.vim
@@ -1,6 +1,7 @@
 command! -nargs=* IPython :call IPyConnect(<f-args>)
 command! -nargs=* IPython2 :call IPyConnect("--kernel", "python2")
 command! -nargs=* IJulia :call IPyConnect("--kernel", "julia-0.4")
+command! -nargs=+ IPyRun1 :call IPyRun(<q-args> . "\r")

 nnoremap <Plug>(IPy-Word) <Cmd>call IPyRun(expand("<cword>"))<cr>
 nnoremap <Plug>(IPy-Run) <Cmd>call IPyRun(getline('.')."\n")<cr>

This creates a command called IPyRun1 that takes care of all the escaping needed to call it from python environment running within vim. Without this, escaping strings to send to jupyter was extremely problematic.

I think this interface will be generally useful too to be included in nvim-ipy.

Thoughts/suggestions?

E117: Unknown function: IPyConnect

This looks like an interesting project; however, I can't get it off the ground. I insall the plugin via BundleInstall, start neovim, and attempt :IPython but I get:

E117: Unknown function: IPyConnect

I've just started using Neovim from Vim, so I may be missing something obvious.

What do you use for output?

The integration nvim -> jupyter works well, but I'd like to view the output in something a little more advanced than a terminal window (think image and rich output).

So far I have a qtconsole (hacked to actually scroll whenever there is new output from the kernel) which works for images but failes for html based output.

There's got to be something better, probably browser based, to approach what vscode now does with it's jupyter integration. Possibly I'm just failing at googling for it.

What do y'all use to view your jupyter output?

Plotting error. Matplotlib using non-gui backend

When trying to plot with matplotlib.plt, using fig.show()

/usr/local/lib/python3.5/dist-packages/matplotlib/figure.py:418: UserWarning: matplotlib is currently using a non-GUI backend, so cannot show the figure
"matplotlib is currently using a non-GUI backend, "

Any idea how to get this working?
Thanks for your help!

How to disable the autocompletion of nvim-ipy

When I active nvim-ipy, YCM seems be disabled, and I can't auto-complete the methods or members of class via YCM. Is there a way that the YCM and nvim-ipy can work cooperatively?

Recent update to all pip packages broke nvim-ipy

Thanks for the previous fix.

However, I unfortunately seemed to have broken nvim-ipy after updating all my global packages.

The error starts when I first start IPython:

error caught while executing async callback:
AttributeError("'NoneType' object has no attribute 'ioloop'",)
Traceback (most recent call last):
  File "/Users/andrewlee/.cache/vimfiles/repos/github.com/bfredl/nvim-ipy/rplugin/python3/nvim_ipy/__init__.py", line 227, in connect
    self.ip_app.initialize(Async(self), argv)
  File "/Users/andrewlee/.cache/vimfiles/repos/github.com/bfredl/nvim-ipy/rplugin/python3/nvim_ipy/__init__.py", line 74, in initialize
    JupyterConsoleApp.initialize(self, argv)
  File "/usr/local/lib/python3.6/site-packages/jupyter_client/consoleapp.py", line 335, in initialize
    self.init_kernel_client()
  File "/Users/andrewlee/.cache/vimfiles/repos/github.com/bfredl/nvim-ipy/rplugin/python3/nvim_ipy/__init__.py", line 65, in init_kernel_client
    self.kernel_client.shell_channel.call_handlers = self.target.on_shell_msg
  File "/usr/local/lib/python3.6/site-packages/jupyter_client/client.py", line 143, in shell_channel
    socket, self.session, self.ioloop
  File "/usr/local/lib/python3.6/site-packages/jupyter_client/threaded.py", line 229, in ioloop
    return self.ioloop_thread.ioloop
AttributeError: 'NoneType' object has no attribute 'ioloop'

the call was requested at
  File "/usr/local/lib/python3.6/site-packages/neovim/api/nvim.py", line 168, in filter_request_cb
    result = request_cb(name, args)
  File "/usr/local/lib/python3.6/site-packages/neovim/plugin/host.py", line 91, in _on_request
    rv = handler(*args)
  File "/usr/local/lib/python3.6/site-packages/neovim/plugin/host.py", line 69, in _wrap_function
    return fn(*args)
  File "/Users/andrewlee/.cache/vimfiles/repos/github.com/bfredl/nvim-ipy/rplugin/python3/nvim_ipy/__init__.py", line 299, in ipy_connect
    Async(self).connect(args)

no request handler registered after installing with vim-plug

After switching from Vundle to vim-plug, re-installing all my plugins without any error, I get the following error when I try to start a kernel:

Error detected while processing function IPyConnect[1]..remote#define#request:                                                                                      
line    2:
Error invoking '/home/soulthym/.config/vim/bundle/nvim-ipy/rplugin/python3/nvim_ipy:function:IPyConnect' on channel 82 (python3-rplugin-host):
no request handler registered for "/home/soulthym/.config/vim/bundle/nvim-ipy/rplugin/python3/nvim_ipy:function:IPyConnect"

Any idea of what's going wrong? I couldn't find a solution in past issues

Does not work on windows trying to open /dev/null

Fails to start on windows with the following error:
capture

I'm not sure if supporting windows is on the feature list, but it appears to be an error not the on the core functionality. Is it possible to solve this problem? Thanks so much for the wonderful tool.

CWD for jupyter is not correctly set in the kernel?

How can I set the CWD for the IPy kernel to be the same as vim? Attempting to open a file through relative paths (nvim-qt) results in an error:
image
Whereas the same exact cell in normal jupyter works properly:
image
Is there any way to set the CWD of jupyter to the same as nvim?

collaboration

So I see you're not really maintaining this repository all that much, but I think that there is some interest in it (by the average neovim user). I would like to propose a collaboration for developing a flexible plugin that will work with jupyter. I didn't quite like how things looked in your plugin, or vim-ipython for that matter. It looks like a big mess and I think we can do better. Documentation is sparse, but I already made quite some progress in discovering how things work and should be used I think. Your plugin and vim-ipython is the start of nvim-jupyter. Let me know what you think.

PS. at the moment the plugin is not functional (I'm waiting for a response to my issue about using the @proerpty decorator), I just started writing it yesterday and it was pretty difficult finding out how things work but I think I am getting the hang of it.

Pdb freezes rest of neovim

When entering the debug mode (it reads "(IPy) (Pdb)" on the lowest line in neovim), the rest of neovim is frozen. It would be nice if it was still possible at least scroll in other buffers. Is that possible?

Regression. E475: Invalid Argument, Channel doesn't exist

Hi bfredl,

Thanks for this wonderful plugin! After the last upgrade (where you defaulted to python3) I start to get this error e475 whenever I use IPy-Run or call IPyRun manual. My neovim is 0.1.3-dev. Even after I delete all other plugins and delete .vimrc this problem persists. Can you look into this please?

IPython --existing doesn't forget previous invocation

As mentioned in the Readme, running :IPython twice causes the old connection to be forgotten. However if the kernel has been created elsewhere using jupyter console (e.g. in another nvim tab) and then you run :IPython --existing twice and start sending instructions to it, they start showing up twice:

nvim-ipy: Jupyter shell for Neovim
Jupyter 4.7.0-final
language: python 3.8.6


In[1]: 1+1
Out[1]: 2

Jupyter 4.7.0-final
language: python 3.8.6

In[2]: 1+1

In[2]: 1+1
Out[2]: 2
Out[2]: 2

Jupyter 4.7.0-final
language: python 3.8.6

In[3]: 1+1

In[3]: 1+1
Out[3]: 2
Out[3]: 2

In[3]: 1+1
Out[3]: 2

(And so on, as :IPython --existing is invoked more and more times.)

Connecting to new jupyter instance fails

After upgrading to jupyter 4.3.0, IPython calls fail to return any error message and opens an empty buffer. Any attempt execute python code in jupyter prompts the "Kernel died, Restart? [Y]es, [N]o" yet typing Y doesn't do anything.
nvim-ipy has been upgraded using Plug and UpdateRemotePlugin has been executed after the upgrade.

autoloading functions

Have you considered moving the functions into a file in an "autoload" dir and moving the syntax expressions into their own syntax file? Itd allow you to take advantage of the pre-existing python architecture in vim

cannot connect to a different kernel after terminate the present one

I created a kernel using :IPython and ran some code in it.
Then I quite the kernel by calling IPyTerminate

Then I tried to run some new code and got the prompt saying "kernal died" and ask me whether to restart the kernel.

If I choose to restart, then the kernel accepts new command.
If I choose not to restart, and using :IPython again trying to create a new kernel or using :IPython --existing xxx.json trying to connect to another existing kernel, nothing happened. No output buffer was created again and no code was executed.

How to connect to a different kernel after quitting the previous one?

Cursor jumps to the bottom line

I've just started using nvim-ipy, which is great for me compared with other similar plugins, except one problem I encounter. In a .py file, cells are created using ##. But, the cursor always jumps to the bottom line if I run one of the following

<Plug>(IPy-Run)
<Plug>(IPy-RunCell)
<Plug>(IPy-RunAll)

The problem remains even if I add the following to init.vim.

let g:ipy_celldef = '^##'

NVIM v0.4.2
macOS 10.14.16

[Edit]

  • If I run <Plug>(IPy-RunCell), only a relevant cell is executed as expected.
  • I expected that the cursor stays or moves to the next cell after executing <Plug>(IPy-RunCell).

Tips for getting this to work on Windows with VIM 7.4 and IPython 3?

Hi,

I realize that neovim does not have a stable Windows GUI build yet and I would really like to use this plugin. I did manage to get VIM 7.4 and Ivanov's original to work on Windows with IPython 2.x. I would at least like to get VIM 7.4 working with IPython 3.x. Are there sections of your code that I could study to understand the changes that you made just from the IPython version 2 to version 3 standpoint? In other words, is Ivanov's work upgradable from the pure VIM standpoint or does it only work with neovim. I understand that the IPython team made some changes to the internal messaging that ipy-vim relied upon.

Thanks!

plugin not working with python 3 kernel - problem with jupyter-client and channels

Hello everyone!

I hope someone can help because this is a strange error and so far I could not find a fix or fix it myself.

Basically just suddently (after a manjaro update; maybe related to python 3.10 ?) my setup of nvim-ipy is not working anymore.
I juse this plugin (and the very same vim-config) since years without any problems.

On Monday, the plugin start (opening the jupyter-console) looked strange and on executing lines I got the message:

jupyter_client not installed

After trying out a lot, getting different errors (all with the same respect), I suspect the problem is somewhere in the "linking/connection" to a channel.

What I did so far:

  • PlugUpdate
  • UpdateRemotePlugins
  • checkhealth
  • downgrading juypter_client, ipython, ipykernel etc..
  • purging all relevant packages/software on my system
  • reinstalling
  • minimizing vim-config to only nvim-ipy

Nothing worked. I would be super happy, if anyone could give me a hint or has a solution or idea what to do!!

Error on executing line:

Error detected while processing function IPyRun[1]..remote#define#notify:
line    6:                                                                                                                                                                                       
E475: Invalid argument: Channel doesn't exist  

My setup right now:

kernel: 5.4.169-1-MANJARO
jupyter 1.0.0
jupyter_client 7.1.0
ipython 7.31.0
ipykernel 6.6.1

(should all be newest)

I have the very same problem on another laptop running a more recent manjaro kernel (but with same python package versions).

output of :checkhealth

coc: health#coc#check
========================================================================
  - OK: Environment check passed
  - OK: Javascript bundle build/index.js found
  - OK: Service started

esearch: health#esearch#check
========================================================================
  - WARNING: Can't find a fast search util executable.
    - ADVICE:
      - Install one of rg, ag, pt or ack.
  - OK: Lua interface is available.
  - OK: Asynchronous processing is available.
  - OK: Floating preview feature is available.
  - OK: Virtual text annotations are available.
  - OK: Unicode icons are available.

floaterm: health#floaterm#check
========================================================================
## common
  - INFO: Platform: linux
  - INFO: Nvim: NVIM v0.6.0
  - INFO: Plugin: 399cb86


## terminal
  - OK: Terminal emulator is available

## floating
  - OK: Floating window is available

nvim: health#nvim#check
========================================================================
## Configuration
  - OK: no issues found

## Performance
  - OK: Build type: Release

## Remote Plugins
  - OK: Up to date

## terminal
  - INFO: key_backspace (kbs) terminfo entry: key_backspace=^H
  - INFO: key_dc (kdch1) terminfo entry: key_dc=\E[3~
  - INFO: $COLORTERM='truecolor'

provider: health#provider#check
========================================================================
## Clipboard (optional)
  - OK: Clipboard tool found: xclip

## Python 2 provider (optional)
  - WARNING: No Python executable found that can `import neovim`. Using the first available executable for diagnostics.
  - ERROR: Python provider error:
    - ADVICE:
      - provider/pythonx: Could not load Python 2:
          /usr/bin/python2 does not have the "neovim" module. :help |provider-python|
          /usr/bin/python2.7 does not have the "neovim" module. :help |provider-python|
          python2.6 not found in search path or not executable.
          /usr/bin/python is Python 3.10 and cannot provide Python 2.
  - INFO: Executable: Not found

## Python 3 provider (optional)
  - INFO: Using: g:python3_host_prog = "/usr/bin/python"
  - INFO: Executable: /usr/bin/python
  - INFO: Python version: 3.10.1
  - INFO: pynvim version: 0.4.3
  - OK: Latest pynvim is installed.

## Python virtualenv
  - OK: no $VIRTUAL_ENV

## Ruby provider (optional)
  - INFO: Ruby: ruby 3.0.3p157 (2021-11-24 revision 3fb7d2cadc) [x86_64-linux]
  - WARNING: `neovim-ruby-host` not found.
    - ADVICE:
      - Run `gem install neovim` to ensure the neovim RubyGem is installed.
      - Run `gem environment` to ensure the gem bin directory is in $PATH.
      - If you are using rvm/rbenv/chruby, try "rehashing".
      - See :help |g:ruby_host_prog| for non-standard gem installations.

## Node.js provider (optional)
  - INFO: Node.js: v14.18.2
  - INFO: Nvim node.js host: /usr/lib/node_modules/neovim/bin/cli.js
  - WARNING: Package "neovim" is out-of-date. Installed: 4.10.0, latest: 4.10.1
    - ADVICE:
      - Run in shell: npm install -g neovim
      - Run in shell (if you use yarn): yarn global add neovim

## Perl provider (optional)
  - ERROR: perl provider error:
    - ADVICE:
      - "Neovim::Ext" cpan module is not installed

vim.lsp: require("vim.lsp.health").check()
========================================================================
  - INFO: LSP log level : WARN
  - INFO: Log path: /home/mreich/.cache/nvim/lsp.log
  - INFO: Log size: 136 KB

vim.treesitter: require("vim.treesitter.health").check()
========================================================================
  - INFO: Runtime ABI version : 13

vimtex: health#vimtex#check
========================================================================
## VimTeX
  - OK: Vim version should have full support!
  - OK: General viewer should work properly!
  - OK: Compiler should work!

Please help!!

marcianito

Add newline to Output

I am using nvim-ipy primarily for data analysis, and I noticed that due to the way the output is displayed, the first row of data (the one in the same row as the Out key word) is always shifted too far right.

This makes looking at tables kind of a pain.

Hence, I propose that a newline is inserted in the Output line in order to fix this display annoyance.

E117: Unknown function: IPyConnect

Like some other issues I get this error:

E117: Unknown function: IPyConnect

When writing :UpdateRemotePlugins I get the following error:

Encountered ModuleNotFoundError loading plugin at /Users/joellidin/.vim/plugged/nvim-ipy/rplugin/python3/nvim_ipy: No module named 'jupyter_client'
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/pynvim/plugin/host.py", line 145, in _load
    module = imp.load_module(name, file, pathname, descr)
  File "/usr/local/Cellar/python/3.7.2_2/Frameworks/Python.framework/Versions/3.7/lib/python3.7/imp.py", line 244, in load_module
    return load_package(name, filename)
  File "/usr/local/Cellar/python/3.7.2_2/Frameworks/Python.framework/Versions/3.7/lib/python3.7/imp.py", line 216, in load_package
    return _load(spec)
  File "<frozen importlib._bootstrap>", line 696, in _load
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
ModuleNotFoundError: No module named 'jupyter_client'
remote/host: python3 host registered plugins []
remote/host: generated rplugin manifest: /Users/joellidin/.local/share/nvim/rplugin.vim

I have the following version of jupyter:

jupyter==1.0.0
jupyter-client==5.2.4
jupyter-console==6.0.0
jupyter-core==4.4.0

My Neovim version is NVIM v0.4.0-dev

EDIT

The problem was in my .vimrc and :python3_host_prog

Integrating with supertab/default completion

One of the 'problems' I have is that I can add a completion to a shortcut (i.e., change from C-F), but I cannot use vim's default completion with nvim-ipy. In turn, this means I cannot use it with Supertab. Is there a way around this?

nevim + python3

Is it possible to make this thing work with neovim that has only python3? I went in the rplugins directory and changed that to python3 instad of python. But that didn't get me too far... I'm getting an error about some channel being closed... There's no option for me but to use python3 on this particular machine... thanks

IPython2 connect unsuccessful

In my impression, it used to work. But on latest update, the plugin failed to connect to IPython2. And by failed to connect, I mean, the iPython buffer is empty and whenever I try to send a line to it, it prompt me kernel died. Connection to IPython3 on the other hand, still works fine.

I am using ipykernel-4.3.1 for python2.

E117: Unknown function: IPyConnect

When running :IPython I get:

E117: Unknown function: IPyConnect

and looking around the codebase, it's true that I can't find that function defined anywhere.

Would it be possible to add information on how to set up the plugin?

Thanks!

E117: Unknown function: IPyConnect

I'm both new to github and the vim word - by which I mean neovim. I saw there was a closed issue on this error , #2 but I was unsure when whether to comment on it or create another issue. As the problem seems to be caused by something else, I decide to open a new issue. Sorry if that's the wrong reasoning.

The error happens when I try :IPython. I ran :UpdateRemotePlugins as indicated in the mentioned issue and the output was:

Encountered ImportError loading plugin at /home/lucasfariaslf/.vim/plugged/nvim-ipy/rplugin/python3/nvim_ipy: No module named 'jupyter_client' Traceback (most recent call last): File "/home/lucasfariaslf/.local/lib/python3.5/site-packages/neovim/plugin/host.py", line 131, in _load module = imp.load_module(name, file, pathname, descr) File "/usr/lib/python3.5/imp.py", line 244, in load_module return load_package(name, filename) File "/usr/lib/python3.5/imp.py", line 216, in load_package return _load(spec) File "<frozen importlib._bootstrap>", line 693, in _load File "<frozen importlib._bootstrap>", line 673, in _load_unlocked ImportError: No module named 'jupyter_client' remote/host: python3 host registered plugins [] remote/host: generated rplugin manifest: /home/lucasfariaslf/.local/share/nvim/rplugin.vim

I tried IPython2 and got the same error, ipython2 kernelspec install-self --user didn't help either.

It seems obvious that the problem might be cause by the lack of this jupyter_client, but I have no idea how to get it to work, as I googled and it's not something I could solve with a pip install.

How to run with a specific version of python?

My neovim uses python2.7 as its default python runtime environment.

But I want nvim-ipy to run with another version python, for example python 2.6. Because some of my works can only works under python 2.6...

So, How to open a nvim-ipy window with a specific version of python?

Possible to use NeoVim terminal?

I just tested on nvim-ipy with a recent version of NeoVim and IPython 4.2.0, and can successfully connect to IPython from NeoVim using :IPython.

Currently, however, commands which are sent to IPython,and the corresponding results are displayed in a NeoVim buffer.

Instead of using a buffer, would it be possible to make use of NeoVim's built-in terminal support? This way, in addition to send commands to the terminal, one could also interact with the IPython console directly in NeoVim.

This has been done with R, for example: https://github.com/jalvesaq/Nvim-R

Is this something that might be possible with IPython as well?

IPyConnect issue

I understand that you already have similar issues posted here. I start nvim from a python2.7 virtualenv which has neovim and pyzmq installed (pip).

Also, I did:

cd rplugin; ln -s python3 python

The neovim config contains

if has('python')
py << EOF
import os.path
import sys
import vim
if 'VIRTUAL_ENV' in os.environ:
    project_base_dir = os.environ['VIRTUAL_ENV']
    sys.path.insert(0, project_base_dir)
    activate_this = os.path.join(project_base_dir, 'bin/activate_this.py')
    execfile(activate_this, dict(__file__=activate_this))
EOF
endif

Hence, should activate that virtualenv within neovim. (Works with jedi.)

:IPython2 yields

no notification handler registered for "/users/is/jredies/.config/nvim/plugged/nvim-ipy/rplugin/python/nvim_ipy:function:IPyConnect"

and :UpdateRemotePlugins yields

function remote#host#UpdateRemotePlugins[6]..<SNR>19_RegistrationCommands[13]..remote#host#Require[13]..provider#pythonx#Require, line 13
Vim(let):E903: Could not spawn API job
function remote#host#UpdateRemotePlugins[6]..<SNR>19_RegistrationCommands[13]..remote#host#Require[13]..provider#pythonx#Require, line 22
Failed to load python3 host. You can try to see what happened by starting Neovim with the environment variable $NVIM_PYTHON_LOG_FILE set to a file and opening the generated log file. Also, the host stderr will be available in Neovim log, so it may contain useful informat
ion. See also ~/.nvimlog.
remote/host: python host registered plugins ['nvim_ipy']
remote/host: generated the manifest file in "/users/is/jredies/.dotfiles/nvim/.init.vim-rplugin~"

/users/is/jredies/.dotfiles/nvim/.init.vim-rplugin~ contains just

" ruby plugins


" python plugins
call remote#host#RegisterPlugin('python', '/users/is/jredies/.config/nvim/plugged/nvim-ipy/rplugin/python/nvim_ipy', [
      \ {'sync': v:false, 'name': 'IPyComplete', 'type': 'function', 'opts': {}},
      \ {'sync': v:true, 'name': 'IPyConnect', 'type': 'function', 'opts': {}},
      \ {'sync': v:false, 'name': 'IPyInterrupt', 'type': 'function', 'opts': {}},
      \ {'sync': v:false, 'name': 'IPyObjInfo', 'type': 'function', 'opts': {}},
      \ {'sync': v:true, 'name': 'IPyOmniFunc', 'type': 'function', 'opts': {}},
      \ {'sync': v:false, 'name': 'IPyRun', 'type': 'function', 'opts': {}},
      \ {'sync': v:false, 'name': 'IPyTerminate', 'type': 'function', 'opts': {}},
     \ ])

Starting nvim with $NVIM_PYTHON_LOG_FILE and running :UpdateRemotePlugins gives the following logfile (and another empty logfile):

2016-04-28 13:42:03,176 [INFO @ script_host.py:setup:50] 45143 - install import hook/path
2016-04-28 13:42:03,176 [INFO @ script_host.py:setup:55] 45143 - redirect sys.stdout and sys.stderr

Integration with vim-airline

First off, thank you for the great plugin!

I use this plugin regularly, and I keep finding myself wishing for a better indication of status. That's why I worked up a minimal implementation of an integration with vim-airline . All it does is show g:ipy_status on the status line.

If this sounds like a good idea, I've got some questions/suggestions:

  1. I'm currently checking whether the current buffer's name is [jupyter]. It feels hacky to me, but I'm not an experienced vimmer.
  2. If we had autocommands for when g:ipy_status changes, the status line can be updated ASAP, as opposed to whenever the status line is next refreshed.
  3. Is there other things to show on the status line (apart from g:ipy_status)? For me, this in itself is sufficient.

I thought it might be better to post on this repo and get things cleared up before submitting a PR to vim-airline.

Documentation

It would be nice if there was documentation for the plugin to be readable inside vim.

Run command as vim operator

Hi,

is it possible to use the run command as a operator on text objects? Often I would like to run the inner paragraph for example or the same indent (with indent textobject plugin).
Also, when opening the ipython buffer, could you set syntax=python automatically?

Thanks a lot!

Add support for jupyter

Hi,
After updating to jupyter I realized that this plugin doesn't work anymore. Is this on the TODO list?

'IPythonPlugin' object has no attribute 'kc'

When I try to auto-complete, I get the error 'AttributeError: 'IPythonPlugin' object has no attribute 'kc''

error caught in async handler '/Users/sky/.dot/nvim/plugged/nvim-ipy/rplugin/python3/nvim_ipy:function:IPyComplete [[]]':
AttributeError("'IPythonPlugin' object has no attribute 'kc'",)
Traceback (most recent call last):
  File "/usr/local/opt/pyenv/versions/3.5.1/lib/python3.5/site-packages/neovim/plugin/host.py", line 91, in _on_notification
    handler(*args)
  File "/usr/local/opt/pyenv/versions/3.5.1/lib/python3.5/site-packages/neovim/plugin/host.py", line 160, in decoder
    return fn(*walk(decode_if_bytes, args, decode))
  File "/Users/sky/.dot/nvim/plugged/nvim-ipy/rplugin/python3/nvim_ipy/__init__.py", line 290, in ipy_complete
    reply = self.waitfor(self.kc.complete(line, pos))
AttributeError: 'IPythonPlugin' object has no attribute 'kc'

I use nvim-ipy in python3.5.11..

Mapping happens anyway, causing collisions while mapping to F5

I just started using the Plugin with NVim coupled with Vundle, and upon installing, the mappings get done even though I set g:nvim_ipy_perform_mappings = 0 in my init.vim

Plugin 'bfredl/nvim-ipy'
let g:nvim_ipy_perform_mappings = 0

then I reload my init.vim and still pressing F5 gives me this error:

error caught in async handler '/home/soulthym/.config/vim/bundle/nvim-ipy/rplugin/python3/nvim_ipy:function:IPyRun [['source ~/.config/vim/vimrc\n']]'            
Traceback (most recent call last):
  File "/home/soulthym/.config/vim/bundle/nvim-ipy/rplugin/python3/nvim_ipy/__init__.py", line 321, in ipy_run
    if self.km and not self.km.is_alive():
AttributeError: 'IPythonPlugin' object has no attribute 'km'
Press ENTER or type command to continue
  1. Shouldn't $HOME/.config/nvim/init.vim be sourced?
  2. why is F5 still mapped after IPy-Run? It forces me to map another shortcut to use IPy-RunCell

is display_svg possible?

Hi, great plugin, I got vim to talk to ipython and was able to produce a matplotlib plot thru %matplotlib qt ; but I couldn't figure out how to display an svg image (nothing shows up but the console doesn't complain, it simply shows the In[10]: line ). It seems that Ipython can display images using a similar approach from here: [(https://stackoverflow.com/questions/28237210/image-does-not-display-in-ipython)]

I tried


from IPython.display import display_svg, SVG
SVG(img.write('svg')) ) #img.write is from another module that writes SVG imgs
display_svg(img)

It works in jupyter. Can it work thru your plugin? Thanks for your time.

Difficulty restarting the kernel

I run :call IPyTerminate() which seems to successfully shut down the kernel. Subsequently running :IPython does instantiate a new process (as seen from Activity Monitor), but there is no connection with the buffer and sending commands to the new kernel doesn't work.

I've tried wiping/closing the IPython buffer after termination and before reinitialization, but to no avail. How else might I be able to conveniently restart the IPython kernel without closing Neovim?

Thanks for any reply! Stoked on this plugin otherwise!

Edit: It seems to restart fine about 70% of the time. Perhaps it is 'luckily' finding the right kernelspec? Forgive my naïveté.

neovim hangs while Scanning: [jupyter]

Occasionally I see the message [Scanning] jupyter appear in the bottom left of neovim. Whilst this is going on, neovim hangs. I cannot edit my code. I assume this is something to do with nvim-ipy but I'm not sure. Does anyone know what's going on? I'm on the latest nvim-ipy github version (commit ad4007f).

Unknown function IPyConnect

Executing :IPython just results in Unknown function IPyConnect and nothing else happens. On a recent master version of nvim.

Signature mismatch

I can create a new seesion using :IPython (yay!) however, when creating a kernel using ipython kernel on the same machine and then using :IPython --existing kerne to communicate from my vim session the communication fails because of a signature mismatch

[Output from the actual kernel]

[IPKernelApp] ERROR | Invalid Message
Traceback (most recent call last):
  File "/home/ubuntu/.virtualenvs/cross/local/lib/python2.7/site-packages/IPython/kernel/zmq/kernelbase.py", line 175, in dispatch_shell
    msg = self.session.deserialize(msg, content=True, copy=False)
  File "/home/ubuntu/.virtualenvs/cross/local/lib/python2.7/site-packages/IPython/kernel/zmq/session.py", line 836, in deserialize
    raise ValueError("Invalid Signature: %r" % signature)
ValueError: Invalid Signature: '51a7d95d58ae497bfb01d4d757d6f978585e9a543140d9d71d7d4ec51fdf7ecf'

I get the same error regardless of starting vim and the kernel in a virtualenv outside.

I can connect to the kernel using ipython console --existing kernel-XXXX.json
What can be happening here?

Suggestion - default map vip<F5>

I'm not sure this is the right place to write this, but I noticed that once you map a key to vip you've basically got yourself a vim implementation of jupyter notebooks. I think this should be included in the default keybinding and mentioned in the readme.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.