joouha / euporie

Jupyter notebooks in the terminal
https://euporie.readthedocs.io
MIT License
1.54k stars 36 forks source link

"command" to go to a specific cell (by cell number and line number) #112

Open IndianBoy42 opened 1 month ago

IndianBoy42 commented 1 month ago

I am trying to write my neovim plugin that opens euporie in a separate terminal but edits the notebook in neovim.

I need a good way to synchronize the cursor position in the editor with the selected cell in euporie and make sure when I hit the "run cell" binding in neovim it runs the correct cell in euporie

it would be nice to be able to send for example c-g # and it selects the cell by number

IndianBoy42 commented 1 month ago

An equivalent to run a specific numbered cell would be nice as well

phromo commented 1 month ago

I desired something similar, but my initial idea was to run euporie-console in a separate terminal and just send cell contents from my editor to the console. I figured there are two ways to send contents to the console:

I actually came here today because I wanted a nicer UX for (2) -- currently the output is appended to the current Out [nn], I want a new Out on each eval.

@joouha if you are willing to describe some thoughts on a "editor integration" epic, I would be happy to code some improvements and add docs. But would be nice to know if this a direction you would accept a PR for.

@IndianBoy42 do you believe sending cells to euporie-console would solve your usecase as well? This mimics the UI of vscode or atom+hydrogen pretty well in that you have a two-pane setup, you edit your notebook in the editor and eval in the second pane. You also use the second pane (euporie-console) to fiddle/debug. To me having the entire notebook open twice seems unnecessary, do you agree?

IndianBoy42 commented 1 month ago

TBH i am currently split on whether the console or notebook view in a separate terminal is better. So in my free time I'm implementing both haha. I have the console version working oka. I kinda like the idea of connecting to the running kernel so the input is not shown, another way to achieve that may be to have euporie support folding/collapsing the input, because sometimes I might actually want to go back in the history and see what code was run for some output.

The main reason i'd have notebook view, or something like it, is to keep the order of the output the same as the code in the notebook and not have multiple copies of the output of the same cell. a notebook view but folding the code cells so mostly only the output is visible could be nice to eliminate the redundancy