-
Notifications
You must be signed in to change notification settings - Fork 30
Execution status and time info on buffer status bar #9
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,7 @@ | |
| from functools import partial, wraps | ||
| from collections import deque | ||
| import os, sys | ||
| import time, datetime | ||
| import json | ||
| import re | ||
| import neovim | ||
|
|
@@ -119,7 +120,6 @@ def __call__(self, msg): | |
| self.is_active = False | ||
|
|
||
| @neovim.plugin | ||
| @neovim.encoding(True) | ||
| class IPythonPlugin(object): | ||
| def __init__(self, vim): | ||
| self.vim = vim | ||
|
|
@@ -155,7 +155,8 @@ def create_outbuf(self): | |
| buf = vim.current.buffer | ||
| buf.options["swapfile"] = False | ||
| buf.options["buftype"] = "nofile" | ||
| buf.name = "[jupyter]" | ||
| self.base_buf_name = "[jupyter]" | ||
| buf.name = self.base_buf_name | ||
| vim.current.window = w0 | ||
| self.buf = buf | ||
|
|
||
|
|
@@ -258,14 +259,17 @@ def ipy_run(self, args): | |
| self.km.restart_kernel(True) | ||
| return | ||
|
|
||
| start_time = time.time() | ||
| self.buf.name = self.base_buf_name + "[*]({})".format(datetime.datetime.now().strftime('%H:%M:%S')) | ||
|
|
||
| reply = self.waitfor(self.kc.execute(code)) | ||
| content = reply['content'] | ||
| payload = content['payload'] | ||
| for p in payload: | ||
| if p.get("source") == "page": | ||
| # TODO: if this is long, open separate window | ||
| self.append_outbuf(p['text']) | ||
|
|
||
| self.buf.name = self.base_buf_name + '({}s elapsed)'.format(time.time()-start_time) | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can't this be done by using
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that it should be possible to have execution time in there. Specifically in a REPL setting would allow to quickly find identify the hotspots in the code by running code line by line without having to modify the code. But maybe all that is needed is to be able to "decorate" each call to the kernel and display the output somewhere. This way it would be possible to wrap each command with code to compute a timedelta.
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. using kernel-side
That should be possible with something like
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree that it is pretty easy once you come up with the idea. It this also works nicely for visual mode: I think I'd be nice to have such a feature out-of-the-box, as not everybody using the plugin should come up with their own a solution. The problem with this solution is that it is python specific.
Good point. The only reason to do it on the client side is that it would work for all kernels and the output could be put anywhere (e.g. airline), avoiding the pollution of the output buffer. If the user is interested in the timing she should not enqueue commands. |
||
| @neovim.function("IPyComplete") | ||
| @ipy_events | ||
| def ipy_complete(self,args): | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why remove this? Note that decoding already is default in python3, so this ensures consistent behaviour also in python2.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This got in by mistake and i thought i had deleted it.