-
Notifications
You must be signed in to change notification settings - Fork 68
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
Behavior choice: Helix keymap #338
Conversation
41851a8
to
cc565bc
Compare
cc565bc
to
a5c3e7d
Compare
Hey there, and thanks for the PR! I haven't looked at everything, but I overall agree with the idea! I don't want to let the perfect be the enemy of the good, but one desire that I had when thinking about letting users switch between Kakoune/Dance/Helix keybindings is supporting multiple keymaps (e.g. non-QWERTY, macOS). Given the large number of keybindings in Dance I would have preferred to change the user's Anyway, it is still good to have a "library" of Helix-specific keybindings; even if the way these keybindings are chosen changes in the future, such a change would be easy to automate following this change. But for now I think I would prefer marking the "behavior" setting as "experimental". I'm also wondering if there might be an overlap between custom modes and behaviors (e.g. maybe instead of behaviors, we could have
This is a good point, I will think about it as well. |
I... actually didn't think of generating a new extension with just keybinding and settings. I'll explore that idea, it feels like it'd be a better way to organize and avoid bloating the package.json further. I'm not a fan of editing The more I think about it, the more I think just having 'namespaced' helix modes and keeping the current kakoune modes as default is probably the least likely to break anything, and also the most simple to handle. Makes it a bit harder to show it as 'experimental' though, since you'd just change the default mode. |
6c0c8bd
to
1916ec6
Compare
Okay, so, turns out making a basic extension with a bunch of keybinds and setting overrides was pretty easy ! It seems to work pretty well, with a couple caveats :
Apart from that, I like it a lot better as a starting point. It's a bit barebones and missing some helix behaviors, but it's probably a better idea to defer those to separate PRs. |
1916ec6
to
7baaa30
Compare
Remove category field from package.json
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 a lot! Sorry again for the delay.
I haven't looked at everything though I did skim over the files (and left a few comments, though they're primarily nits / code style).
Seeing the helix: select
commands inline like that while knowing that they won't "bloat" the extension is pretty cool!
I think I'm mostly worried about code duplication; I think that I'd like to get to a point where Dance is Dance "Core" + Dance "Kakoune" (or Dance "Helix"), so we would benefit from reusing the same code/assets/package.json
build machinery for all extensions.
package.build.ts
Outdated
@@ -22,7 +22,7 @@ const builtinModesAreDeprecatedMessage = | |||
"Built-in modes are deprecated. Use `#dance.modes#` instead."; | |||
|
|||
const modeNamePattern = { | |||
pattern: /^[a-zA-Z]\w*$/.source, | |||
pattern: /^[a-zA-Z]\w*\/?\w*$/.source, |
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.
pattern: /^[a-zA-Z]\w*\/?\w*$/.source, | |
pattern: /^[a-zA-Z]\w*(\/\w+)$/.source, |
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.
Wait, doesn't that regex force having a slash somewhere ? I think a ?
is missing after the group maybe ?
@@ -655,6 +653,36 @@ function getKeybindings(module: Omit<Builder.ParsedModule, "keybindings">) { | |||
].sort((a, b) => a.command.localeCompare(b.command)); | |||
} | |||
|
|||
export function generateIgnoredKeybinds( |
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: spelling
export function generateIgnoredKeybinds( | |
export function generateIgnoredKeybindings( |
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.
Could you also add a documentation string? By looking at the source code I can fairly easily know what it does, but the name itself isn't enough to understand what is returned.
extensions/helix/package.build.ts
Outdated
"": { | ||
hiddenSelectionsIndicatorsDecoration: { | ||
after: { | ||
color: "$list.warningForeground", | ||
}, | ||
backgroundColor: "$inputValidation.warningBackground", | ||
borderColor: "$inputValidation.warningBorder", | ||
borderStyle: "solid", | ||
borderWidth: "1px", | ||
isWholeLine: true, | ||
}, | ||
}, | ||
"input": { | ||
cursorStyle: "underline-thin", | ||
}, |
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.
If these two entries are omitted does Dance stop working normally?
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.
From quick testing, it doesn't, I just copy pasted the base settings because I wasn't sure what to with those.
415cac9
to
438baf3
Compare
438baf3
to
10e50a9
Compare
Yah, no worries, there's no hurry, and this thing's become a sizeable PR 😅. I'll have to think about how to deduplicate the package generating code, I'm not sure exactly which part would benefit from abstracting yet. |
If you'd like I can take care of this; we could submit your PR soon (either to
For me, it would include all the Dance commands and API, but none of the keybindings. That way you would install the "Kakoune keybindings" or "Helix keybindings", both of which would depend on "Dance Core", and you would only get the keybindings you need. With this model, I guess we would create a new extension "Dance Core", and migrate the current extension to be "Dance with Kakoune keybindings".
"Dance Core" (the extension) would be different from |
I'd be okay with that, if that works for you ! It'll also allow me to submit the couple other helix-related PRs I'm working on :)
Ah I see, that makes a lot more sense when thinking of it this way. Might make sense to rename the 'core' category to avoid confusion in that case, but that's a small issue. |
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 again did not much time to review until now.
I tried it out and it's nice! I opened a PR in Strackeror#1 to work on reusing some of the logic.
src/commands/misc.ts
Outdated
* | Add the digit 9 to the counter | `9` (core: normal), `NumPad9` (core: normal) | `[".updateCount", { addDigits: 9 }]` | | ||
* | Title | Keybinding | Command | | ||
* | ------------------------------ | -------------------------------------------------------------------------------------------- | ------------------------------------ | | ||
* | Add the digit 0 to the counter | `0` (core: normal), `NumPad0` (core: normal), `0` (helix: select), `NumPad0` (helix: select) | `[".updateCount", { addDigits: 0 }]` | |
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.
Does (core: normal, helix: select)
not work? I don't remember if I implemented this, but I can see several keybindings in your PR (and even from before your PR) which could benefit from such a syntax.
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.
As of right now it doesn't (I would have felt like quite an idiot if it did !). But it actually sounds like a good idea, so I'll see if I can implement that, it would help make things less verbose !
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.
Well, I did it. It's separated by ;
instead of ,
because otherwise the regex would conflict with the one for tags, but it seems to work quite well
It's not consistent, but vscode sometimes gives me errors about the semver for the helix package not being valid, and indeed it seems leading zeroes are not valid semver, so switching to a tag to mark the prerelease
hey guys, where's this sitting? any way an excited bystander can help get this over the line? :) |
Any updates to this? |
@@ -22,7 +22,7 @@ const builtinModesAreDeprecatedMessage = | |||
"Built-in modes are deprecated. Use `#dance.modes#` instead."; | |||
|
|||
const modeNamePattern = { | |||
pattern: /^[a-zA-Z]\w*$/.source, | |||
pattern: /^[a-zA-Z]\w*(\/\w+)?$/.source, |
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.
You were absolutely right, I had this in mind.
Hey all. I'm sincerely sorry for the delay; I had some minor anxiety looking at GitHub notifications for the past ~6 months, but am going to try to get this submitted soon. Before I merge this PR, can someone please help with the following:
|
@@ -62,3 +61,22 @@ export async function toMode(modeName: string, count?: number) { | |||
})); | |||
}, 0); | |||
} | |||
|
|||
/** | |||
* Returns the {@link Mode} with the given name, prioritizing one that's within the name "namespace" |
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.
optional nit: my bad, my suggestion had a typo
* Returns the {@link Mode} with the given name, prioritizing one that's within the name "namespace" | |
* Returns the {@link Mode} with the given name, prioritizing one that's within the same "namespace" |
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.
Review the PR, preferably someone with experience with Helix, and who has submitted code to Dance before
I don't strictly match either of those criteria: my only PR is small and still in review, and I'm a Helix novice, who wants to use Dance with this PR to learn Helix.
I'm not familiar enough with Helix to be able to point out any glaring differences in behaviour here. However, I have been running this branch as my daily driver at work for a long time now, and it's been reliable and useful, and I have no issues with any of its defaults.
It is somewhat incomplete in terms of all the commands that are available, however I personally am not bothered by that; I wouldn't want to attempt to achieve perfection before merging this, I'd much rather have the basics in place and settled. It's easy enough to add (and contribute!) any glaring omissions (btw - i have 80% of a match menu :) ).
|
||
"package-helix:pre": `cd extensions/helix && yarn run package:pre`, | ||
"publish-helix:pre": `cd extensions/helix && yarn run publish:pre`, |
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.
When I run these, I get an error - "can't find extension/assets/dance.png". I believe vsce
is whinging about assets
being a symlink.
I'm confused why you guys aren't hitting this though - are you developing on Windows by any chance? I'm on Linux. Am I just building it wrong?
I'm looking into if bumping to @vscode/vsce 3.2.2 gets it working for me - they've added a --follow-symlinks option, however this is very recent (newer than this PR).
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 up, yes bumping vsce
and adding --follow-symlinks
in a few places gets things building. However I'm confused why it's evidently just me being hit by this?
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.
I hit the same issue (macOS). Using @vscode/[email protected]
with --follow-symlinks
as suggested fixed it, thanks! Opened Strackeror#2 to fix.
I'll try to daily-drive this for a few days. My keybindings with |
Oh boy, been a while since there's been some activity in here :)
This branch is definitely meant as a first step for other helix integrations down the line. I have a much more complete reproduction of helix behavior down in my |
|
Would it make sense to include the |
Agreed, "chasing perfection" is the main reason why I couldn't open GH notifications for several months, so even if it's incomplete I'd be happy to merge the PR. Just want to make sure it's a good basis for future changes. @kabouzeid These will likely be useful (thanks for the input!), but won't block this PR from being submitted first. |
I'm not sure how much sense it makes to have the Helix "helper" extension. As it stands, the main extension defines the keybindings, while the helper extension only adds the modes and menus. I don’t see an easy way to move the keybindings to the helper extension as well. Given that the two can't be cleanly separated, it might make more sense to keep everything in the main extension rather than adding complexity. The user can still easily enable Helix mode with a single config option: |
Also just noticed, currently the registers for yank, delete etc are set to the system clipboard. Should be the |
@kabouzeid I agree, ideally they would also be part of the same extension but I'm worried about scaling: the Dance extension registers ~300 keybindings, and adding an Helix mode (then later different keybindings for macOS, then different keybindings for different keyboard layouts like AZERTY) could easily bump this to >500 keybindings. These bloat views like "Keyboard Shortcuts", and I haven't benchmarked anything but it's possible VS Code is not happy to evaluate the That said I'm open to ideas which would allow us to keep a single extension without significant drawbacks (or benchmarks which prove the drawbacks mentioned above aren't that bad). |
How about stop worrying about the imperfection and just merge it, make a preview release and see how it goes. It is not a mission critical piece of software that once pushed to a planet, which is a hundred million miles away from the Earth, cannot be reverted. VSCode made it quite easy to switch between versions. |
@cloudhan Unfortunately the extension doesn't currently build. I proposed a solution in Strackeror#2 but as pointed out by the author of this PR, it would be better to have different files rather than symlinks. I will tackle it when I get some time, but it may not happen for a while (so, PRs welcome). Edit: I submitted Strackeror#4 to fix this. |
@71 On Windows 11, the only problem I encountered is EDIT: not yet, seem vsce is dispatch in a wrong folder, aka, not from dir where package.json is located, but from the project root. |
Here is some build artifact on Windows |
04a891c
to
257713d
Compare
And: - Update LICENSE to ~2025. - Add purple Dance logo for Helix.
Thank you all again for bearing with me here, especially @Strackeror! Sorry again for the delay. We now have a strong base to build on, so future changes should be far simpler to merge. |
I've been using Dance with a custom helix-like set of keybindings for more than a year now, and I just wanted to thank everybody involved in getting this PR merged! The quality of this extension is exceptionally high, and by integrating helix bindings, I hope it will see additional adoption. Thanks maintaining it. Really amazing work! 🫶 |
Awesome stuff guys, thanks heaps :) |
Awesome, thanks! Let's refine and add the missing functionality with focused PRs that can be merged quickly :) |
Ayyy, it's done ! Glad this is getting out there, more improvements coming soon :) |
Hey there !
So I've been maintaining a personal use fork of dance with helix keybindings for a while now, but I've been seeing some of the keybinds making their way into the original codebase (with plans for more in #323), so I thought I'd just go ahead and try to remake it in a way that could fit into the main project.
So, here is a draft for a 'behavior' choice, where a user could choose which base keymap to use from a single setting. This is currently just the basic normal and select mode keymaps, without any of the helix menus, but it's a good starting point to show how it would look like in practice.
Currently the handling in the commands file is pretty naive, with a lot of duplication for the select mode. And I'm not sure on the backward compatibility when adding a new condition to a lot of keybindings like that, so I'm very open to discussion.