joouha / euporie

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

Feature request: Some ideas for improving input cells #14

Closed yingzhu146 closed 2 years ago

yingzhu146 commented 3 years ago

First off: absolutely stoked to see this project - comes so close to my ideal workflow that I got very excited brainstorming additional suggestions. Thanks a ton!

Right now, my jupyter TUI workflow is essentially using Neovim on a left kitty split and ptipython on the right side (i.e. ptpython using the ipython shell. This works surprisingly well for everything (and works across every language, too, just need a REPL). Here's some ideas coming from that.

There is a couple of niceties that ptpython does that would be absolutely fantastic to have in euporie

1) improved vim mode:

ptpython allows you to use vim on an individual input cell. right now to my understanding euporie only allows it on a notebook level, however this basically forces me to use e for every simple edit, which is kind of disturbing to the workflow since I have to do e -> <edit thing> -> :x -> ctrl-r.

Cooler would be if it would be solved like in the jupyterlab vim extension where single escape gets you to normal mode in a jupyter notebook level and shift escape or double escape gets you to vim mode on a notebook level. Another way to remove friction here is to make a write of the temp file executes the respective cell, so we could at least get rid of the last ctrl-r (by the time of write I'm pretty committed to executing it so the ctrl-r feels superfluous).

It would also be helpful to make sure that the tempfile has the right filetype (e..g use .py ending to make sure the editor filetype recognition works and you have LSP etc available)

2) function signatures and other advanced features (or even LSP support)?

image

3) autosuggestion

4) completion while typing

(3/4 look something like this in practice)

image

5) Variable viewer

Like the jupyterlab equivalent

joouha commented 3 years ago

Some really great ideas here.

(1.a) Execute cells immediately after editing in external editor

This would be a useful addition. I've added it in a8be410.

(1.b) Use .py suffix for tempfiles when editing in external editor

This is very straight forward to implement - I've added it in ad24358.

It would be nice to generalize this further, so if using irkernel we use a .r suffix, if using julia we use a .jl suffix, etc.

(2) Function signatures in completion suggestions

I'm not sure if it is possible to access these through a jupyter kernel, I'll have to do some reading. It will be possible to add in the completion type column (e.g. function, class, module, etc.), as jupyter returns those along with completions (although this appear to still be experimental).

(3) Autosuggestion / completion while typing

Would you expect autosuggestions to come from elsewhere in the notebook, from ipython history, or to autosuggest completions?

Completion while typing is might by tricky, as there is often a slight wait for completions from jupyter, so we'd need to be careful to ensure that this does not add input latency.

(4) Variable viewer

Maybe one day :wink:

yingzhu146 commented 3 years ago

Wow thanks a lot, super cool and excited to give this a try!

(2) Function signatures in completion suggestions

I'm not sure if it is possible to access these through a jupyter kernel, I'll have to do some reading. It will be possible to add in the completion type column (e.g. function, class, module, etc.), as jupyter returns those along with completions (although this appear to still be experimental).

So one way would be to get idea 2 just by providing LSP integration, which is obviously a pretty huge feature https://github.com/krassowski/jupyterlab-lsp. Or to use jedi like ptpython does?

(3) Autosuggestion / completion while typing

Would you expect autosuggestions to come from elsewhere in the notebook, from ipython history, or to autosuggest completions?

From all past history of jupyter notebooks, identical to the ipython/shell behavior.

Completion while typing is might by tricky, as there is often a slight wait for completions from jupyter, so we'd need to be careful to ensure that this does not add input latency.

(4) Variable viewer

Maybe one day 😉

🤞

joouha commented 2 years ago

Quick update on this

I've implemented autocompletion while typing and and autosuggestions from history (these are configurable, and can be switched on and off from the settings menu).

These will both be available in the next release

image

joouha commented 2 years ago

I've added the ability to automatically show contextual help when typing, which contains function signatures: image

This can be enabled from the settings menu (or manually summoned with Shift+Tab).

I'm going to mark this issue as closed now, as I have now implemented all of your suggestions (except for the variable viewer, which I've added to my roadmap).

:slightly_smiling_face:

yingzhu146 commented 2 years ago

Amazing, really enjoying it!