-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
[WIP] Support Vim mode in notebook #1109
Conversation
Thanks @parleur I'll try to look at that soon ! |
High level comments: Could we have a tick marker on the menu for the currently use keymap ? |
} | ||
codemirror.setOption(opt, value); | ||
}); | ||
var that = this; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
forgotten var that=this ?
OK, I think that we want to avoid vim shortcut for now, at it seem to be complex. Get the logic right for default/emacs/sublime, and deals with vim later. |
Regardless of that, pretty sweet, and seem to mostly work for me. |
vimMode = true; | ||
this.keyboard_manager.mode = 'vim-command'; | ||
} else if ( keymap === 'sublime' || keymap === 'default') { | ||
vimMode = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you set vimMode to null
, the update option will remove the key from the config file, which is cleaner I think.
Awesome, people are going to be really happy about this. |
Sweet! Have you had a chance to try @ivanov 's vimception? |
This looks sweet. @parleur Can you provide some context on what changes were made and where review is most helpful? THanks!! |
Closed? Did you find an alternative way to implement it? |
I think @parleur want a bit less attention, and yes, we discussed an alternative for vim keybinding, and had a long conversation on how key handling works in general in the notebook. |
ah great, thanks @Carreau. I'm interested in helping out with "emacs mode" if/when there's an opening. |
The emacs key bindings are not that hard, the issue is with Vim that already have a dual command/edit mode. We (@parleur and I) think it should be possible to "never" be in jupyter command mode, and have extra keybindings for codemirror that trigger actions at notebook level. So you can do things like if (this.mode === 'edit') {
return this.edit_shortcuts.call_handler(event);
} else if (this.mode === 'command') {
return this.command_shortcuts.call_handler(event);
} by something like: new_mode = this.mode[this.current_mode].call_handler(event)
this.current_mode = new_mode To gain some flexibility, and some patching of markdown cell to switch the rendering on focus. |
^ @Carreau I like that idea |
bb3eac0
to
d252ec0
Compare
I think you might need to rebase. |
A stupid question: you suggest to rebase on top on current master:HEAD, I am used to merge new HEAD into my dev branch ( I ve read somewhere, it is dangerous to rebase any published commit ). I am wrong? Or is it equivalent ? |
Usually we avoid merging with HEAD. I can show you how to rebase next Tuesday on Skype if you like. |
Also current commit is parleur@2832c13 So now that it is linked here, whatever you do, we can get it back from GitHub. |
A little comment about dynamic Codemirror keymap switching. |
Another solution would be forcing to reload page after switching keymap.. |
Hmm it would solve the Codemirror bug ... but likely raise other issues. At minimum auto saving before reloading and handle interrupt computation due to keymap switching |
We can likely assume people won't switch keymaps too many time. So I think reloading (with a warning) is acceptable if we want to go this route. |
f81ac18
to
93947c1
Compare
|
THanks for fixing things upstream. In general CodeMirror is released monthly, so we never have to wait too much between releases. |
related extension: https://github.com/lambdalisue/jupyter-vim-binding |
This PR in now close. After many time spent on in it appears that dealing a keymap layer need a proper keyevent handling, and it is not a refacto that can be done under the hood here. |
I wonder if Neovim's embedding functionality could be used for this, like how ActualVim works, rather than just reimplementing vim-mode like every other project with a vim emulation mode. |
This pull request is functional but not usable right now.
It switches the keybindings of all codemirror instance (inspired by the editor). It obviously raises issue in UI interface I aim to discuss here.
That's it. Feel free to discuss, that's the main purpose of this PR