Skip to content

Commit

Permalink
use call instead of eval
Browse files Browse the repository at this point in the history
  • Loading branch information
bfredl committed Aug 13, 2015
1 parent f154afd commit 1761d94
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions rplugin/python/nvim_ipy.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,12 +211,11 @@ def connect(self, argv):
vim.command("set ft={}".format(lang))
# FIXME: formatting is lost if shell window is closed+reopened
for i in range(len(banner)):
vim.eval("matchaddpos('Comment', [{}])".format(i+1))
vim.funcs.matchaddpos('Comment', [i+1])

vim.funcs.matchadd('IPyIn', self.re_in)
vim.funcs.matchadd('IPyOut', self.re_out)

vim.vars["ipy_regex_in"] = self.re_in
vim.vars["ipy_regex_out"] = self.re_out
vim.eval(r"matchadd('IPyIn', g:ipy_regex_in)")
vim.eval(r"matchadd('IPyOut', g:ipy_regex_out)")

vim.current.window = w0

Expand Down Expand Up @@ -249,7 +248,7 @@ def ipy_connect(self, args):
def ipy_run(self, args):
(code,) = args
if self.km and not self.km.is_alive():
choice = int(self.vim.eval("confirm('Kernel died. Restart?', '&Yes\n&No')"))
choice = int(self.vim.funcs.confirm('Kernel died. Restart?', '&Yes\n&No'))
if choice == 1:
self.km.restart_kernel(True)
return
Expand All @@ -269,7 +268,7 @@ def ipy_complete(self,args):
#FIXME: (upstream) this sometimes get wrong if
#completing just after entering insert mode:
#pos = self.vim.current.buffer.mark(".")[1]+1
pos = int(self.vim.eval("col('.')"))-1
pos = self.vim.funcs.col('.')-1

if ipy3:
reply = self.waitfor(self.kc.complete(line, pos))
Expand All @@ -281,8 +280,7 @@ def ipy_complete(self,args):
start = content["cursor_start"]+1
else:
start = pos-len(content['matched_text'])+1
matches = json.dumps(content['matches'])
self.vim.command("call complete({}, {})".format(start,matches))
self.vim.funcs.complete(start, content['matches'])

@neovim.function("IPyObjInfo")
@ipy_events
Expand Down Expand Up @@ -374,5 +372,4 @@ def on_hb_msg(self, time_since):
self.disp_status("DEAD")

def on_stdin_msg(self, msg):
self.vim.vars['ipy_prompt'] = "(IPy) " + msg["content"]["prompt"]
self.kc.input(self.vim.eval("input(g:ipy_prompt)"))
self.kc.input(self.vim.funcs.input("(IPy) " + msg["content"]["prompt"]))

0 comments on commit 1761d94

Please sign in to comment.