Better interface to IPyRun
randomgeek78 opened this issue · 0 comments
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?