From 4017060e413bc5f7de75a0e29649927ee9c13773 Mon Sep 17 00:00:00 2001 From: Roderick Date: Sat, 3 Oct 2015 01:32:10 +0200 Subject: [PATCH] added information to the buffer statusbar to know when IPython is running and the execution duration --- rplugin/python/nvim_ipy.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/rplugin/python/nvim_ipy.py b/rplugin/python/nvim_ipy.py index a3928ed..5053e85 100644 --- a/rplugin/python/nvim_ipy.py +++ b/rplugin/python/nvim_ipy.py @@ -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,6 +259,9 @@ 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'] @@ -265,7 +269,7 @@ def ipy_run(self, args): 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) @neovim.function("IPyComplete") @ipy_events def ipy_complete(self,args):