-
Notifications
You must be signed in to change notification settings - Fork 67
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
Allow ordinary menus #353
Allow ordinary menus #353
Conversation
Ooooh, that's a great way to do a simple command palette, I'm stealing this for my fork :) |
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.
Thanks for the contribution! From what I see it should be easy to merge.
camel_case exorcized, description/help text added to jsonschema, and more efficient "what was picked?" implemented. thanks for review! |
package.build.ts
Outdated
}, | ||
{ | ||
const: "hotkey", | ||
description: "A `hotkey` menu is used to give a menu and keybinds emulating Helix's multi-key Static Commands, e.g. [g]oto → [e]nd." |
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.
Ah this should be a kakoune example sorry, will fix up when I get a chance
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.
Thanks! Feel free to take your time if you want to improve documentation or something.
src/api/menu.ts
Outdated
const choice = await promptOne(items, (quickPick) => quickPick.title = menu.title); | ||
|
||
let choice: string | number; | ||
if ((menu.menuType ?? 'hotkey') == 'hotkey') { |
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.
nit (sorry):
if ((menu.menuType ?? 'hotkey') == 'hotkey') { | |
if ((menu.menuType ?? 'hotkey') === 'hotkey') { |
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.
No stress, thanks for picking up.
A general note: you seem to put a lot of effort into making sure contributions follow good+consistent code style. This is fine but probably means thorough review takes a lot of your time!
Would you consider setting up a linter to automate this? Things like Biome are amazingly fast these days, and as a contributor it means I can check (and sometimes even autofix!) these things before you even need to read them.
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.
That's a great point! I really need (and want) to set this up, but haven't done so yet. Nowadays I mostly work with Deno, so I'll need to either migrate existing lints to Deno or learn other linters and formatters. I similarly want to adopt a new code style (damn me, having to always "Save Without Formatting" in VS Code), but that requires applying it to the whole repo and breaking pending PRs.
package.build.ts
Outdated
description: "A `hotkey` menu is used to give a menu and keybinds emulating Helix's multi-key Static Commands, e.g. [g]oto → [e]nd." | ||
} | ||
], | ||
description: 'meny type test', |
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.
Please fix :)
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.
Ahh oops! Soz
package.build.ts
Outdated
@@ -361,6 +361,20 @@ export const pkg = (modules: Builder.ParsedModule[]) => ({ | |||
title: { | |||
type: "string", | |||
}, | |||
menuType: { | |||
anyOf: [ |
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.
anyOf
is more of an "advanced" JSON Schema feature. In VS Code markdownEnumDescriptions
is better supported.
7ec1274
to
f878e62
Compare
should be good now, sorry I'm not sure if you want you or me to resolve the feedback so I'll leave to you :) EDIT: following on from the linter discussion above, I ran eslint for the first time.. i hadn't done this, oops. This raised that the typescript |
Is this one waiting on anything from me? Apart from maybe removing 'wip' from the title :) |
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.
Thanks!
I've hence included a commit to bump typescript to the latest
Sounds good, thanks.
Two small comments and then I'll approve.
@@ -165,7 +187,7 @@ export async function showMenuAfterDelay( | |||
const pickedItem = menu.items[itemKeys], | |||
args = mergeArgs(pickedItem.args, additionalArgs); | |||
|
|||
return Context.WithoutActiveEditor.wrap( | |||
await Context.WithoutActiveEditor.wrap( |
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.
This should be followed by a return
statement (unless that's intentional?).
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.
eep, great catch thanks.
package.build.ts
Outdated
@@ -361,6 +361,18 @@ export const pkg = (modules: Builder.ParsedModule[]) => ({ | |||
title: { | |||
type: "string", | |||
}, | |||
menuType: { |
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.
Sorry I only think about this now, but what about type
? menu.menuType: palette
is a bit redundant.
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.
done!
Co-authored-by: Grégoire Geis <[email protected]>
c9b8a04
to
3d5c57d
Compare
@jwhitaker-gridcog Thank you!
Works great, thanks! |
Heya, thanks for maintaining this.
When playing with Strackeror's great Helix mode contribution, I was having trouble getting a command-hx menu to feel right due to the single hot key system. E.g. distilled to a three item menu, "fmt / Format", "w / Write", and "wbc / Write and Close",
w
andwbc
can't be distinguished in the current system.As a proof of concept, I wondered if menus could have a
menu_type: "hotkey"
(current behaviour, and default) or alternatively amenu_type: "palette"
, which is just a stock-standard vscode quickpick. Palette menus don't have the hotkey system but can just use vscode's already great type/select system which I've been using locally quite happily.Demo:
Kooha-2024-12-18-08-42-33.webm.mp4
From menus config:
This probably isn't wired up the best way, but was hoping to get some feedback on if this would be accepted in principal or not before fiddling further.
Thanks!