jupyterlab-contrib / jupyterlab-vim

Vim notebook cell bindings for JupyterLab
https://jupyterlab-contrib.github.io/jupyterlab-vim.html
MIT License
691 stars 43 forks source link

Updates for Jupyterlab 4 #68

Closed ianhi closed 1 year ago

ianhi commented 2 years ago

EDIT - How to get working jlab4

Version 0.17.0 and up should work in jlab4 please upgrade via python -m pip install jupyterlab_vim --upgrade


I looks as thought jupyterlab 4 will use codemirror 6: https://github.com/jupyterlab/jupyterlab/pull/11638 which drops the built in vim.

Fortunately it looks like replit has taken over maintenance of the vim extension and has updated it for CM6: https://github.com/replit/codemirror-vim#vim-keybindings-for-cm6. We should try to implement using this new package well before release to see if any changes in jlab will be necessary for this extension to continue to work.

firai commented 2 years ago

I understand from replit/codemirror-vim that the new extension needs to be loaded in the CM extension configuration before all other keymaps, including the basic one. I'm looking at the new JLab 4 API architecture, but I haven't figured out yet whether it allows replacing the keymap in the EditorConfiguration in packages/codemirror/src/editorconfiguration.ts, which is eventually be fed into EditorView of createEditor in packages/codemirror/src/editor.ts. It seems like injectExtension of EditorConfiguration only appends the extension in the configuration, which (I presume) would not achieve what the CM vim extension requires.

firai commented 2 years ago

By the way, it seems like this upcoming JLab PR might also have a significant impact on the upgrade? https://github.com/jupyterlab/jupyterlab/pull/12554

ianhi commented 2 years ago

thanks @firai! I left a comment on that PR asking about this.

I'm looking at the new JLab 4 API architecture, but I haven't figured out yet whether it allows replacing the keymap in the EditorConfiguration in packages/codemirror/src/editorconfiguration.ts, which is eventually be fed into EditorView of createEditor in packages/codemirror/src/editor.ts. It seems like injectExtension of EditorConfiguration only appends the extension in the configuration, which (I presume) would not achieve what the CM vim extension requires.

We may need to open an issue on jlab to discuss this. Probably better to do so sooner rather than later if we are going to need changes in jlab. Unfortunately I don't think I'll have the bandwidth to think about this for the next few weeks - so if anyone wants to take the lead on pushing on this please do :)

firai commented 2 years ago

Thanks @ianhi! Is it worth mentioning in your comment on the JLab windowing PR that the replit/codemirror-vim keymap has to be before the others in the init in order to work, rather than just adding it to the end?

ianhi commented 2 years ago

Is it worth mentioning in your comment on the JLab windowing PR that the replit/codemirror-vim keymap has to be before the others in the init in order to work, rather than just adding it to the end?

yup definitely worthwhile. I think we ought to compile a starting list of what APIs we need that don't exist in the new API an open an issue about that.

firai commented 1 year ago

It seems like JLab 4 has now hit RC status. The extension migration guide is at https://jupyterlab.readthedocs.io/en/latest/extension/extension_migration.html.

rsvdr commented 1 year ago

It seems like JLab 4 has now hit RC status. The extension migration guide is at https://jupyterlab.readthedocs.io/en/latest/extension/extension_migration.html.

I tried running the script but the extension still does not work in Jupyterlab 4.

ianhi commented 1 year ago

I tried running the script but the extension still does not work in Jupyterlab 4.

I think that that script is necessary but not sufficient. The source of the vim bindings will also need ot be updated as they no longer ship with codemirror. We will now need to get them via: https://github.com/replit/codemirror-vim#vim-keybindings-for-cm6

Finally we will likely also have to change how we interact with jupyterlab codemirror as it seems that that interface has also changed.

OracleMachine commented 1 year ago

I tried running the script but the extension still does not work in Jupyterlab 4.

I think that that script is necessary but not sufficient. The source of the vim bindings will also need ot be updated as they no longer ship with codemirror. We will now need to get them via: https://github.com/replit/codemirror-vim#vim-keybindings-for-cm6

Finally we will likely also have to change how we interact with jupyterlab codemirror as it seems that that interface has also changed.

As an avid user of the JupyterLab-Vim extension, I'm eager to contribute to its updates. Can you provide an overview of the current plan? I may be relatively new to developing JupyterLab extensions, but I've familiarized myself with the documentation. It seems we might need to reconfigure the Vim bindings to accommodate the Replit version of the CodeMirror interface. Please let me know how I can assist in this process.

vilanele commented 1 year ago

Hello,

I'm an avid user of JupyterLab-Vim too and first I thank you for your work. For now I'm using JupyterLab version 3.6.x, but it should be great to have it working on 4.x.x. If I can assist I'll be pleased let me know.

Just few words of encouragement.

paul-turing-ml commented 1 year ago

Also just chiming in to say thanks to everyone who has worked / is working on this project - I can barely function without it! Is there some place I can donate? Or if I can provide some other sort of support, please let me know.

dirkroorda commented 1 year ago

I got to the point that I have tried VSCode for running Jupyter notebooks. It's been a good experience so far. Easy to get vim bindings and black working in code cells. It's a pity that the vim bindings have not made it to the main Jupyter code. Thanks for this extension that has been a much appreciated asset when working in JupyterLab!

krassowski commented 1 year ago

A PR adding support for JupyterLab 4.0 is up: https://github.com/jupyterlab-contrib/jupyterlab-vim/pull/85 - please help with testing and review.

ianhi commented 1 year ago

85 has been merged and released!

Install

python -m pip install jupyterlab_vim --upgrade in an environment with jupyterlab4 should get you working install.

Thanks

Huge thanks to @krassowski for doing the work on converting the extension!

dirkroorda commented 1 year ago

I'm back with JupyterLab. After a short spell of using VSS code.