Skip to content
This repository was archived by the owner on Nov 7, 2025. It is now read-only.

Conversation

@DerWeh
Copy link

@DerWeh DerWeh commented Apr 9, 2017

I added wmvanvliet's wmvanvliet's run_cell function, to emulate a cell mode.

The collection of lines is implemented in python which should be faster. Please check if I adjusted the code the right way, as I only tried to emulate your ipy_run function with his code and I actually don't know how neovim plug-ins work.

The cell separators should probably be refactored into a vimscript variable, to be configurable.

min_indent = indent

# Perform dedent
if min_indent > 0:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't be necessary, IPython kernel will strip off largest common indent of a cell automatically.


# Execute cell
lines = "\n".join(cur_buf[upper_bound:lower_bound+1])
reply = self.waitfor(self.kc.execute(lines, silent=silent))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here instead just call self.ipy_run

cur_buf = self.vim.current.buffer
(cur_line, cur_col) = self.vim.current.window.cursor
cur_line -= 1
def is_cell_separator(line):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can probably be implemented much simpler vimL-side, where we can use ordinary regex search(). Instead we should probably have a Python function IPyRunLines which takes a line range.

@bfredl
Copy link
Owner

bfredl commented Nov 4, 2017

I implemented cells vimscript side on master. See the "Cells" section in readme.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants