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’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

Closed
sudormrfbin opened this issue Aug 7, 2021 · 14 comments · Fixed by #1400
Closed

VS Code like command palette to search for commands and keybinds #559

sudormrfbin opened this issue Aug 7, 2021 · 14 comments · Fixed by #1400
Labels
A-helix-term Area: Helix term improvements C-discussion Category: Discussion or questions that doesn't represent real issues C-enhancement Category: Improvements E-good-first-issue Call for participation: Issues suitable for new contributors E-help-wanted Call for participation: Extra attention is needed

Comments

@sudormrfbin
Copy link
Member

VS Code has a command palette that allows searching for commands and keybindings by their description and executing them:

vs code command palette

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.

@sudormrfbin sudormrfbin added the C-enhancement Category: Improvements label Aug 7, 2021
@sudormrfbin
Copy link
Member Author

sudormrfbin commented Aug 7, 2021

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.

@pickfire pickfire added the C-discussion Category: Discussion or questions that doesn't represent real issues label Aug 11, 2021
@pickfire
Copy link
Contributor

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.

@sudormrfbin
Copy link
Member Author

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 g but don't know the exact keymap for goto references, you can press g and look it up in the infobox.

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).

@pickfire
Copy link
Contributor

pickfire commented Aug 18, 2021

Hmm, any idea what keybind it should use? Or the flow?

@archseer
Copy link
Member

Space+? could work, since ? is already a common shortcut on websites (try it here on github and you'll get a popup).

If we want to actually make these executable, then maybe Ctrl+Space (it reminds me of Cmd+Space to bring up Spotlight on macOS)

@pickfire
Copy link
Contributor

pickfire commented Aug 19, 2021

So I guess every command now will need to have description, default mode and default key specified there?

@pickfire pickfire added E-easy Call for participation: Experience needed to fix: Easy / not much A-helix-term Area: Helix term improvements labels Aug 19, 2021
@sudormrfbin
Copy link
Member Author

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).

@sudormrfbin
Copy link
Member Author

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.

@heliostatic
Copy link
Contributor

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 :Commands command in https://github.com/junegunn/fzf.vim#commands is also great.

CleanShot.2021-09-25.at.21.44.05.mp4

@kirawi
Copy link
Member

kirawi commented Nov 3, 2021

We can probably reuse the existing picker for this.

@kirawi kirawi added E-good-first-issue Call for participation: Issues suitable for new contributors E-help-wanted Call for participation: Extra attention is needed and removed E-easy Call for participation: Experience needed to fix: Easy / not much labels Nov 11, 2021
@matoous
Copy link
Contributor

matoous commented Dec 23, 2021

Going to take a look at this one if no one has started working on it already.

@sudormrfbin
Copy link
Member Author

I started working on this a few months back but hit a roadblock with not being able to access the keymap outside of helix-term. The proper solution to that was to move components and keymaps to helix-view which I tackled in #711, but other PRs took up my time.

@archseer
Copy link
Member

If you're just building a picker in helix-term (inside a Command), isn't that enough? I forgot how @Omnikar handled it in the :help PR

@Omnikar
Copy link
Contributor

Omnikar commented Dec 23, 2021

Accessing the keymaps from the :help command function has not been handled as of now.

archseer added a commit that referenced this issue Feb 17, 2022
* 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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-helix-term Area: Helix term improvements C-discussion Category: Discussion or questions that doesn't represent real issues C-enhancement Category: Improvements E-good-first-issue Call for participation: Issues suitable for new contributors E-help-wanted Call for participation: Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants