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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

vim/emacs modes with settings #2173

Merged
merged 8 commits into from Aug 22, 2023
Merged

vim/emacs modes with settings #2173

merged 8 commits into from Aug 22, 2023

Conversation

kenichi
Copy link
Contributor

@kenichi kenichi commented Aug 21, 2023

adds user settings (default: false) and support for both vim and emacs keybindings in monaco editors, via monaco-vim and monaco-emacs packages

notes:

  • mostly a spike based on the discussion in Option to have more Vim key bindings in code editor聽#715
  • disclaimer: i don't know emacs keys at all! 馃槃 would love it if someone who does can test
  • deals with the current LB escape key conflict by adding a data-vim-mode attr to the parent element and checking for "insert" value during handling
  • unsure of automated testing approach... 馃

does this seem like a valid approach that is in line with livebook requirements/direction?

@CLAassistant
Copy link

CLAassistant commented Aug 21, 2023

CLA assistant check
All committers have signed the CLA.

@github-actions
Copy link

github-actions bot commented Aug 21, 2023

Uffizzi Preview deployment-34012 was deleted.

Copy link
Member

@jonatanklosko jonatanklosko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@josevalim feel free to merge if this works for you :)

@josevalim josevalim merged commit 9f96bd2 into livebook-dev:main Aug 22, 2023
7 checks passed
@josevalim
Copy link
Contributor

馃挌 馃挋 馃挏 馃挍 鉂わ笍

@isti115
Copy link

isti115 commented Dec 6, 2023

(Sorry to bump an already merged PR, but I'm not sure that this deserves a separate issue.)
Are there any drawbacks to the idea of exposing the VimMode object from monaco-vim to the window scope in order to allow users the addition of custom keybindings?
(The global Monaco instance is already supposedly exposed since #1642, I couldn't seem to access it though. 馃)

@jonatanklosko
Copy link
Member

The global Monaco instance is already supposedly exposed since #1642, I couldn't seem to access it though.

That's a regression from migrating to esbuild, fixed in ad562b8.

As for exposing VimMode, honestly this feels like too much. Is your idea to write a custom browser extension that looks for that global and defines custom shortcuts, or something else?

@isti115
Copy link

isti115 commented Dec 9, 2023

@jonatanklosko Thanks for the fix!
Regarding VimMode, a simple userscript would be enough, for example this is the code I use to inject a custom mapping into the CodeMirror based Overleaf editor:

// ==UserScript==
// @name         Overleaf Editor Custom VIM Keybindings
// @version      0.1
// @match        https://www.overleaf.com/project/*
// @grant        none
// ==/UserScript==

window.addEventListener("UNSTABLE_editor:extensions", (event) => {
  const { CodeMirrorVim } = event.detail;
  CodeMirrorVim.Vim.map("jk", "<Esc>", "insert");
});;

@jonatanklosko
Copy link
Member

@isti115 I added a global in b7fabe1, no future guarantees though :)

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.

None yet

5 participants