-
-
Notifications
You must be signed in to change notification settings - Fork 80
[Feature] customize keymaps #443
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
base: main
Are you sure you want to change the base?
Conversation
Implements [[artisticat1#400](https://github.com/superle3/obsidian-latex-suite/issues/400)](https://github.com/artisticat1/obsidian-latex-suite/issue/400). This adds an easy framework to add keymaps. Looking at the implementation of [keymap.ts](https://github.com/codemirror/view/blob/main/src/keymap.ts), it was clear rolling our own keymap would be more trouble than its worth, as a lot of "magic" things were happening there. Using the default keymap also doesn't work as that has the default priority and we need the highest priority. As such we use their api `runScopeHandeler` instead and attach our own custom scope (the name of this plugin). This way we only have to standardize the formatting of the `key` instead of dealing with the complicated `KeyBoardEvent`. This currently only adds customization for the snippet Trigger key and the tabout trigger key, as I haven't seen any feature requests for the other keys and that would needlessly add configuration.
e7ff14e to
0ded4da
Compare
| })); | ||
| new Setting(containerEl) | ||
| .setName("Key trigger for tabout") | ||
| .setDesc("What key to press to trigger tabout. Key names may be strings like \"Shift-Ctrl-Enter\" a key prefixed with zero or more modifiers. Modifiers can be given in any order. Shift- (or s-), Alt- (or a-), Ctrl- (or c- or Control-), Cmd- (or m- or Meta-) or Mod- (Cmd- on Mac, Ctrl- on Windows/Linux) are recognized. Chords are seperated by a space.") |
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.
also not satisfied with this explanation
| .addDropdown((dropdown) => dropdown | ||
| .addOption("Tab", "Tab") | ||
| .addOption(" ", "Space") | ||
| .setDesc("What key to press to expand non-auto snippets. Key names may be strings like \"Shift-Ctrl-Enter\" a key prefixed with zero or more modifiers. Modifiers can be given in any order. Shift- (or s-), Alt- (or a-), Ctrl- (or c- or Control-), Cmd- (or m- or Meta-) or Mod- (Cmd- on Mac, Ctrl- on Windows/Linux) are recognized. Chords are seperated by a space.") |
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.
Not satisfied with this explanation. Am inclined to just point them to the official docs of https://codemirror.net/docs/ref/#view.KeyBinding, but that might be a bit much. Maybe like no explanation here or a small example and mention it in the DOCS.md? since we have to explain the triggerKey there arleady.
| flags: optional(string_()), | ||
| priority: optional(number()), | ||
| description: optional(string_()), | ||
| triggerKey: optional(string_()), |
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.
following the same style here, but defaultvalue and validator could also be used.
Resolves #439.
Resolves #400.
Resolves #409.
Rely on @codemirror/view for handling keymaps instead rolling our own. This allows for more customization later on.
I looked at the implementation of https://github.com/codemirror/view/blob/main/src/keymap.ts to see if it was worth it to roll our own keymap handling, but it was a bit too complex to include it, thus this relies on their implementation and adds the scope
latex-suitesuch this extension only triggers it.