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

Add IPyRunCell function to execute a cell. #30

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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 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.

2 participants