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

feat: add Helix-based select mode and its most common keybindings #301

Merged
merged 6 commits into from
Jun 15, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,7 @@ export function parseKeys(keys: string) {
case "normal":
case "insert":
case "input":
case "select":
whenClauses.push(`dance.mode ${negate ? "!=" : "=="} '${tag}'`);
break;

Expand Down
21 changes: 19 additions & 2 deletions package.build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ export const pkg = (modules: Builder.ParsedModule[]) => ({
}],
],
},
select: {},
normal: {
lineNumbers: "relative",
decorations: {
Expand Down Expand Up @@ -758,18 +759,34 @@ export const pkg = (modules: Builder.ParsedModule[]) => ({
...symbols.map((x) => `Shift+${x}`),
]);

const keysToAssignForNormal = new Set(keysToAssign);
const keysToAssignForVisual = new Set(keysToAssign);

for (const keybinding of keybindings) {
keysToAssign.delete(keybinding.key);
if (keybinding.when.includes("dance.mode == 'normal'")) {
keysToAssignForNormal.delete(keybinding.key);
}
if (keybinding.when.includes("dance.mode == 'select'")) {
keysToAssignForVisual.delete(keybinding.key);
}
}

for (const keyToAssign of keysToAssign) {
for (const keyToAssign of keysToAssignForNormal) {
keybindings.push({
command: "dance.ignore",
key: keyToAssign,
when: "editorTextFocus && dance.mode == 'normal'",
});
}

for (const keyToAssign of keysToAssignForVisual) {
keybindings.push({
command: "dance.ignore",
key: keyToAssign,
when: "editorTextFocus && dance.mode == 'select'",
});
}

return keybindings;
})(),
},
Expand Down
Loading