Skip to content
Draft
Show file tree
Hide file tree
Changes from all 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
39 changes: 0 additions & 39 deletions assets/dance.svg

This file was deleted.

5 changes: 5 additions & 0 deletions extensions/kakoune/LICENSE
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.
3 changes: 3 additions & 0 deletions extensions/kakoune/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Dance - Kakoune keybindings

Kakoune keybindings for VS Code based on [Dance](https://github.com/71/dance).
File renamed without changes
Empty file.
4 changes: 4 additions & 0 deletions src/state/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import type { Commands } from "../commands";
import { extensionName } from "../utils/constants";
import { AutoDisposable } from "../utils/disposables";
import { assert, CancellationError } from "../utils/errors";
import { watchKeymaps } from "../utils/keymaps";
import { SettingsValidator } from "../utils/settings-validator";
import { onDidLoadTreeSitter, type TreeSitter } from "../utils/tree-sitter";

Expand Down Expand Up @@ -189,6 +190,9 @@ export class Extension implements vscode.Disposable {

// Tree Sitter support.
this._subscriptions.push(onDidLoadTreeSitter((treeSitter) => this._treeSitter = treeSitter));

// Sanity checks
this._subscriptions.push(watchKeymaps());
}

/**
Expand Down
64 changes: 64 additions & 0 deletions src/utils/keymaps.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import * as vscode from "vscode";

/**
* Watches extensions, displaying warnings if potential conflicts are detected.
*/
export function watchKeymaps(): vscode.Disposable {
return vscode.extensions.onDidChange(checkKeymaps);
}

function checkKeymaps(): void {
/** Map from mode name to contributing extensions. */
const contributedModes = new Map<string, string[]>();
let hasConflict = false;

// Find extensions that contribute Dance modes.
for (const extension of vscode.extensions.all) {
const packageJSON = extension.packageJSON;
const modes = packageJSON?.contributes?.configurationDefaults
?.["dance.modes"];

if (typeof modes !== "object") {
continue;
}

const extensionName = extension.packageJSON?.displayName ??
extension.packageJSON?.name;
const extensionDisplayName = extensionName === undefined
? extension.id
: `${extensionName} (${extension.id})`;

for (const mode in modes) {
const existing = contributedModes.get(mode);

if (existing === undefined) {
contributedModes.set(mode, [extensionDisplayName]);
} else {
existing.push(extensionDisplayName);
hasConflict = true;
}
}
}

if (!hasConflict) {
return;
}

// Aggregate conflicting extensions.
const conflictingExtensions = new Set<string>();

for (const extensionNames of contributedModes.values()) {
if (extensionNames.length > 1) {
for (const extensionName of extensionNames) {
conflictingExtensions.add(extensionName);
}
}
}

// Display error message.
vscode.window.showWarningMessage(
`Multiple extensions contribute conflicting Dance modes: ${
Array.from(conflictingExtensions).sort().join(", ")
}`,
);
}
Loading