-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
VS Code like command palette to search for commands and keybinds #559
Comments
I wrote a plugin, cheatsheet.nvim, that attempts to bring this concept to neovim by having short files that describe a set of commands (it does a little more than that, but it's not relevant here). Even though I don't use it all the time (like I imagined I would ha ha), when I need it I'm quite thankful for it. After a proper plugin system is introduced to helix, this could help in making plugin commands and keybindings more accessible to end users. |
I don't think merging them would be a good idea because of how a modal editor work. vscode is always in insert mode like emacs so it's fine for them to have it, but model editor you would not want to type them out. I think it would be better if we show the infobox when we press a key like F1 in any part. |
The idea isn't to merge the infobox with this; the infobox and the command palette are completely different in what they perform and are complementary. The infobox is useful to guide your keypresses as you type, for example if you know that all the goto commands are under But if you know nothing about the keymap to invoke (or if you've simply forgotten it), you will either have to go read the docs or do trial and error. This is where the command palette can be useful -- you can search for a keymap by it's description and don't have to worry about memorizing a plethora of keys. And executing the commands from the palette would probably not be feasible because of modes, but that's not the primary function I hope to achieve with this anyway (though that would be a nice addition). |
Hmm, any idea what keybind it should use? Or the flow? |
If we want to actually make these executable, then maybe |
So I guess every command now will need to have description, default mode and default key specified there? |
We can simply get that information from the keymap itself by recursively traversing it (the mode is at the top level, keys and descriptions are at the bottom level of the keymap tree). |
We can merge the unbound commands to the command list after the recursive traversal parsing and show all of them. Also commands without default keybinds are a prime use case for executing commands from the palette, though that would need extra information like the mode it is supposed to work in. |
Although it's a GUI, Obsidian handles the command palette in a modal editor well -- commands are mode specific, and keybindings are shown when they exist. The CleanShot.2021-09-25.at.21.44.05.mp4 |
We can probably reuse the existing picker for this. |
Going to take a look at this one if no one has started working on it already. |
I started working on this a few months back but hit a roadblock with not being able to access the keymap outside of |
If you're just building a picker in |
Accessing the keymaps from the |
* feat(commands): command palette Add new command to display command pallete that can be used to discover and execute available commands. Fixes: #559 * Make picker take the whole context, not just editor * Bind command pallete * Typable commands also in the palette * Show key bindings for commands * Fix tests, small refactor * Refactor keymap mapping, fix typo * Ignore sequence key bindings for now * Apply suggestions * Fix lint issues in tests * Fix after rebase Co-authored-by: Blaž Hrastnik <[email protected]>
VS Code has a command palette that allows searching for commands and keybindings by their description and executing them:
I've found this to be very useful when acquainting myself with the editor, since I don't have to try and remember every single keybinding, nor do I have to continuously switch to a documentation page to figure out how to do something (for the most part). It also helps immensely with discoverability since all possible key mappings are laid out and you're bound to stumble into something useful sooner or later.
VS Code allows executing entries from the command palette itself, I'm not sure whether that should be supported, since most commands aren't free standing and need further or previous input.
This shouldn't be too hard since we already have short descriptions for both editor commands (keybindings) and typable commands, and a picker to search through them.
The text was updated successfully, but these errors were encountered: