Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH Start a new Ipython kernel from vim #94

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

luispedro
Copy link
Contributor

This is a bit hacky, but it works well enough:

  1. generate a new random ID
  2. use the subprocess to start a completely new IPython kernel process
    with that ID. This may not even be the same Python version that vim
    is running (this is a feature, not a bug)
  3. connect to this kernel

Currently, the kernel is automatically killed at exit.

This is a bit hacky, but it works well enough:

1. generate a new random ID
2. use the subprocess to start a completely new IPython kernel process
   with that ID. This may not even be the same Python version that vim
   is running (this is a feature, not a bug)
3. connect to this kernel

Currently, the kernel is automatically killed at exit.
@bfredl
Copy link

bfredl commented Jul 16, 2014

Another also somewhat hacky solution is

from IPython.core.application import BaseIPythonApplication
from IPython.consoleapp import IPythonConsoleApp
class IPythonVimApp(BaseIPythonApplication, IPythonConsoleApp):
    def initialize(self, argv):
        super(IPythonVimApp, self).initialize(argv)
        IPythonConsoleApp.initialize(self, argv)
app = IPythonVimApp()
app.initialize([]) # or ['--profile', 'julia'] or ['--existing']
km = app.kernel_manager
kc = app.kernel_client

This has the benefit that it accepts the same arguments as ipython console/notebook <argv> (to start non-python kernels for instance) and it can interrupt and restart the kernel using the kernel_manager interface, not sure how backward (or forward) compatible it is though.

@ivanov
Copy link
Owner

ivanov commented Jul 16, 2014

thanks both for the contributions here, I'll take a look and get this is later on today.

@ivanov
Copy link
Owner

ivanov commented Jul 16, 2014

Talking this over with @minrk, we'll be better off using KernelManager to do this, so I'll merge this for now, but extend it to use that (less hacky) machinery

@ivanov
Copy link
Owner

ivanov commented Jul 17, 2014

Thanks for the contribution, @luispedro - I rebased this commit and it became 80eecbd. Then I just used the KernelManager machinery to start the kernel instead (cf54530). Let me know how that goes for you.

Conflicts:
	ftplugin/python/ipy.vim
@ches
Copy link

ches commented Jul 26, 2015

Seems this PR can be closed 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants