-
Notifications
You must be signed in to change notification settings - Fork 79
Behavior choice: Helix keymap #338
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
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
a5c3e7d
Behavior choice: Basic helix keymap
Strackeror 7baaa30
Behavior choice: Helix keymap as an extension
Strackeror 7e1a759
Fix shift+c in helix modes
Strackeror 8babb7f
Fix missing editorTextFocus condition
Strackeror 1b71b25
Add `%` binding to helix
Strackeror 91bc9d6
Fix binding: `Shift+R`
Strackeror 10e50a9
PR Fixes
Strackeror a1f82a7
Fix typos and title, add toggle indices
Strackeror 38be042
Add numpad bindings to select mode
Strackeror 0887662
PR Fixes
Strackeror 47c2737
Improve keybind parsing for less verbose definitions
Strackeror 77882fd
use symlinks
71 e908946
Fix invalid pre-release version string
Strackeror 943ffc1
fix go to menu items
karimknaebel f09050a
Keymap: Add switch back to normal mode on some keybinds
Strackeror 257713d
remove symlinks
71 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| Copyright 2020-2025 Grégoire Geis | ||
|
|
||
| Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. | ||
|
|
||
| THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| # Dance - Helix keybindings | ||
|
|
||
| Helix keybindings for VS Code based on [Dance](https://github.com/71/dance). |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,207 @@ | ||
| // Save to package.json | ||
| // ============================================================================ | ||
|
|
||
| import { Builder, generateIgnoredKeybinds } from "../../meta"; | ||
| import * as fs from "fs/promises"; | ||
| import { extensionId } from "../../src/utils/constants"; | ||
|
|
||
| const version = "0.1.0", | ||
| preRelease = 1, | ||
| preReleaseVersion = `${version}-pre${preRelease}`; | ||
|
|
||
| export const pkg = (modules: Builder.ParsedModule[]) => ({ | ||
|
|
||
| // Common package.json properties. | ||
| // ========================================================================== | ||
|
|
||
| name: "dance-helix-keybindings", | ||
| description: "Helix keybindings for Dance", | ||
| version, | ||
| license: "ISC", | ||
| extensionDependencies: [extensionId], | ||
| author: { | ||
| name: "Grégoire Geis", | ||
| email: "opensource@gregoirege.is", | ||
| }, | ||
Strackeror marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| contributors: [ | ||
| { | ||
| name: "Rémi Lavergne", | ||
| url: "https://github.com/Strackeror", | ||
| }, | ||
| ], | ||
|
|
||
| repository: { | ||
| type: "git", | ||
| url: "https://github.com/71/dance.git", | ||
| }, | ||
|
|
||
| engines: { | ||
| vscode: "^1.63.0", | ||
| }, | ||
|
|
||
| displayName: "Dance (Helix keybindings)", | ||
| publisher: "gregoire", | ||
| categories: ["Keymaps", "Other"], | ||
| readme: "README.md", | ||
| icon: "assets/dance.png", | ||
| extensionKind: ["ui", "workspace"], | ||
|
|
||
| scripts: { | ||
| "package": "vsce package --allow-star-activation", | ||
| "publish": "vsce publish --allow-star-activation", | ||
| "package:pre": `vsce package --allow-star-activation --pre-release --no-git-tag-version --no-update-package-json ${preReleaseVersion}`, | ||
| "publish:pre": `vsce publish --allow-star-activation --pre-release --no-git-tag-version --no-update-package-json ${preReleaseVersion}`, | ||
| }, | ||
|
|
||
| contributes: { | ||
| configurationDefaults: { | ||
| "dance.defaultMode": "helix/normal", | ||
| "dance.modes": { | ||
| "helix/insert": { | ||
| onLeaveMode: [ | ||
| [".selections.save", { | ||
| register: " insert", | ||
| }], | ||
| ], | ||
| }, | ||
| "helix/select": { | ||
| cursorStyle: "block", | ||
| selectionBehavior: "character", | ||
| }, | ||
| "helix/normal": { | ||
| cursorStyle: "block", | ||
| selectionBehavior: "character", | ||
| decorations: { | ||
| applyTo: "main", | ||
| backgroundColor: "$editor.hoverHighlightBackground", | ||
| isWholeLine: true, | ||
| }, | ||
| onEnterMode: [ | ||
| [".selections.restore", { register: " ^", try: true }], | ||
| ], | ||
| onLeaveMode: [ | ||
| [".selections.save", { | ||
| register: " ^", | ||
| style: { | ||
| borderColor: "$editor.selectionBackground", | ||
| borderStyle: "solid", | ||
| borderWidth: "2px", | ||
| borderRadius: "1px", | ||
| }, | ||
| until: [ | ||
| ["mode-did-change", { include: "normal" }], | ||
| ["selections-did-change"], | ||
| ], | ||
| }], | ||
| ], | ||
| }, | ||
| }, | ||
|
|
||
| "dance.menus": { | ||
| match: { | ||
| title: "Match", | ||
| items: { | ||
| // Should be jump in normal mode, extend in select mode, but jump for seek.enclosing is not implemented | ||
| "m": { command: "dance.seek.enclosing", text: "Goto matching bracket" }, | ||
| "a": { command: "dance.openMenu", args: [{ menu: "object", title: "Match around" }], text: "Select around object" }, | ||
| "i": { command: "dance.openMenu", args: [{ menu: "object", title: "Match inside", pass: [{ inner: true }] }], text: "Select inside object" }, | ||
| }, | ||
| }, | ||
|
|
||
| object: { | ||
| title: "Select object...", | ||
| items: ((command = "dance.seek.object") => ({ | ||
| "()": { command, args: [{ input: "\\((?#inner)\\)" }], text: "parenthesis block" }, | ||
| "{}": { command, args: [{ input: "\\{(?#inner)\\}" }], text: "braces block" }, | ||
| "[]": { command, args: [{ input: "\\[(?#inner)\\]" }], text: "brackets block" }, | ||
| "<>": { command, args: [{ input: "<(?#inner)>" }], text: "angle block" }, | ||
| '"': { command, args: [{ input: "(?#noescape)\"(?#inner)(?#noescape)\"" }], text: "double quote string" }, | ||
| "'": { command, args: [{ input: "(?#noescape)'(?#inner)(?#noescape)'" }], text: "single quote string" }, | ||
| "`": { command, args: [{ input: "(?#noescape)`(?#inner)(?#noescape)`" }], text: "grave quote string" }, | ||
| "w": { command, args: [{ input: "[\\p{L}_\\d]+(?<after>[^\\S\\n]+)" }], text: "word" }, | ||
| "W": { command, args: [{ input: "[\\S]+(?<after>[^\\S\\n]+)" }], text: "WORD" }, | ||
| "p": { command, args: [{ input: "(?#predefined=paragraph)" }], text: "paragraph" }, | ||
| "a": { command, args: [{ input: "(?#predefined=argument)" }], text: "argument" }, | ||
| "!": { command, text: "custom object desc" }, | ||
| }))(), | ||
| }, | ||
|
|
||
| view: { | ||
| "title": "View", | ||
| "items": { | ||
| "cz": { text: "Align view center", command: "dance.view.line", args: [{ "at": "center" }] }, | ||
| "t": { text: "Align view top", command: "dance.view.line", args: [{ "at": "top" }] }, | ||
| "b": { text: "Align view bottom", command: "dance.view.line", args: [{ "at": "bottom" }] }, | ||
| "k": { text: "Scroll view up", command: "editorScroll", args: [{ "by": "line", "revealCursor": true, "to": "up" }] }, | ||
| "j": { text: "Scroll view down", command: "editorScroll", args: [{ "by": "line", "revealCursor": true, "to": "down" }] }, | ||
| "/": { text: "Search for regex pattern", command: "dance.search" }, | ||
| "?": { text: "Reverse search for regex pattern", command: "dance.search.backward" }, | ||
| "n": { text: "Select next search match", command: "dance.search.next" }, | ||
| "N": { text: "Select previous search match", command: "dance.search.previous" }, | ||
| }, | ||
| }, | ||
|
|
||
| goto: { | ||
| title: "Goto", | ||
| items: { | ||
| "g": { text: "to line number else file start", command: "dance.select.lineStart", "args": [{ "count": 1 }] }, | ||
| "e": { text: "to last line", command: "dance.select.lineEnd", args: [{ count: 2 ** 31 - 1 }] }, | ||
| "f": { text: "to file/URLs in selections", command: "dance.selections.open" }, | ||
| "h": { text: "to line start", command: "dance.select.lineStart" }, | ||
| "l": { text: "to line end", command: "dance.select.lineEnd" }, | ||
| "s": { text: "to first non-blank in line", command: "dance.select.lineStart", args: [{ skipBlank: true }] }, | ||
| "d": { text: "to definition", command: "editor.action.revealDefinition" }, | ||
| "r": { text: "to references", command: "editor.action.goToReferences" }, | ||
| "j": { text: "to last line", command: "dance.select.lastLine" }, | ||
| "t": { text: "to window top", command: "dance.select.firstVisibleLine" }, | ||
| "c": { text: "to window center", command: "dance.select.middleVisibleLine" }, | ||
| "b": { text: "to window bottom", command: "dance.select.lastVisibleLine" }, | ||
| "a": { text: "to last buffer", command: "workbench.action.openPreviousRecentlyUsedEditorInGroup" }, | ||
| "A": { text: "to last buffer...", command: "workbench.action.quickOpenPreviousRecentlyUsedEditorInGroup" }, | ||
| "n": { text: "to next buffer", command: "workbench.action.nextEditor" }, | ||
| "p": { text: "to previous buffer", command: "workbench.action.previousEditor" }, | ||
| ".": { text: "to last buffer modification position", command: "dance.selections.restore", args: [{ register: " insert" }], | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
|
|
||
| keybindings: (() => { | ||
| const ignoredKeybindings = [], | ||
| keybindings = modules | ||
| .flatMap((module) => module.keybindings) | ||
| .filter((keybinding) => ["core", "helix", undefined].includes(keybinding.category)) | ||
| .map(({ category, ...kb }) => kb); | ||
|
|
||
| for (const mode of ["normal", "select", "insert"]) { | ||
| for (const keybind of keybindings) { | ||
| keybind.when = keybind.when.replace(`dance.mode == '${mode}'`, `dance.mode == 'helix/${mode}'`); | ||
| } | ||
| } | ||
|
|
||
| for (const mode of ["normal", "select"]) { | ||
| const whenMode = `editorTextFocus && dance.mode == 'helix/${mode}'`; | ||
| ignoredKeybindings.push(...generateIgnoredKeybinds( | ||
| keybindings.filter(key => key.when.includes(whenMode)), | ||
| whenMode, | ||
| )); | ||
| } | ||
|
|
||
| return [ | ||
| ...keybindings, | ||
| ...ignoredKeybindings, | ||
| ]; | ||
| })(), | ||
| }, | ||
| }); | ||
|
|
||
|
|
||
| export async function build(builder: Builder) { | ||
| await fs.writeFile( | ||
| `${__dirname}/package.json`, | ||
| JSON.stringify(pkg(await builder.getCommandModules()), undefined, 2) + "\n", | ||
| "utf-8", | ||
| ); | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.