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

[Feature] Allow quick selecting nui menu items by number or letter #240

Open
akinsho opened this issue Feb 18, 2023 · 1 comment
Open

[Feature] Allow quick selecting nui menu items by number or letter #240

akinsho opened this issue Feb 18, 2023 · 1 comment

Comments

@akinsho
Copy link

akinsho commented Feb 18, 2023

Hi 👋🏿,

Thanks for working on this plugin, it's been great to see it become a central library for a lot of other plugins. I wanted to float the idea of a Nui menu feature to you. The idea is to add an API to allow users using a Nui menu (if opted in via the plugin etc.) to quickly select a menu item based on a letter or number (e.g. it's position). I worked briefly with @.windwp on a similar menu for codeactions in https://github.com/nvim-pack/lsp-fastaction.nvim (archived now) but I think the general feature was useful.

This would look something like

|  1. Item 1  |
|  2. Item 2  |
|  3. Item 3  |

and you could select 2 by pressing that number. Alternatively it could be letter based e.g.

|  (W)ater  |
|  (A)pple  |
|  (F)ish   |

And you'd select them using the letter.

I appreciate that probably a plugin author could get something like this working with some logic internal to their plugin (maybe), but I think the value of doing it at this level is that it could be done consistently and if the barrier to entry was low enough could be more easily used or could be something that the option could be passed down from the user themselves and done automatically for the user without the involvement of the plugin author using your library.

As to the exact API (that's of course largely up to you) but you could do the numbers simply by the items index in a the list and then just prefix the number as a visual indicator for the user and then have buffer local mapping for the numbers to select them straight away.

This could work similarly for the letter maybe choosing the first letter and mapping those locally in that buffer as well.

Anyway been mulling over a way to revive the pattern @.windwp came up with and this seems the nicest place for it where it could have the best reach.

@zcsh0721
Copy link

#353

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

No branches or pull requests

2 participants