aboutsummaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorChristoph Herzog <chris@theduke.at>2020-06-22 20:48:22 +0200
committerRobert Helgesson <robert@rycee.net>2020-09-04 14:14:52 +0200
commit1ed8e7ef98db46af84e6be02f6538250f2ef259f (patch)
tree8ac9f1f9d0f8cd6476e472b880a7055b59a80c0c /modules
parente6e49ad73c7d8cbd9f6622f0a3330ce7b71c8a86 (diff)
vscode: add options for keybindings
Adds a new `keybindings` option to the `vscode` configuration. It contains a list of key bindings, which will be written to `%vscode-dir%/User/keybindings.json`. PR #1351
Diffstat (limited to 'modules')
-rw-r--r--modules/programs/vscode.nix52
1 files changed, 49 insertions, 3 deletions
diff --git a/modules/programs/vscode.nix b/modules/programs/vscode.nix
index 8e8fba777ce..099760c834a 100644
--- a/modules/programs/vscode.nix
+++ b/modules/programs/vscode.nix
@@ -20,11 +20,14 @@ let
"vscodium" = "vscode-oss";
}.${vscodePname};
- configFilePath =
+ userDir =
if pkgs.stdenv.hostPlatform.isDarwin then
- "Library/Application Support/${configDir}/User/settings.json"
+ "Library/Application Support/${configDir}/User"
else
- "${config.xdg.configHome}/${configDir}/User/settings.json";
+ "${config.xdg.configHome}/${configDir}/User";
+
+ configFilePath = "${userDir}/settings.json";
+ keybindingsFilePath = "${userDir}/keybindings.json";
# TODO: On Darwin where are the extensions?
extensionPath = ".${extensionDir}/extensions";
@@ -59,6 +62,45 @@ in
'';
};
+ keybindings = mkOption {
+ type = types.listOf (types.submodule {
+ options = {
+ key = mkOption {
+ type = types.str;
+ example = "ctrl+c";
+ description = "The key or key-combination to bind.";
+ };
+
+ command = mkOption {
+ type = types.str;
+ example = "editor.action.clipboardCopyAction";
+ description = "The VS Code command to execute.";
+ };
+
+ when = mkOption {
+ type = types.str;
+ default = "";
+ example = "textInputFocus";
+ description = "Optional context filter.";
+ };
+ };
+ });
+ default = [];
+ example = literalExample ''
+ [
+ {
+ key = "ctrl+c";
+ command = "editor.action.clipboardCopyAction";
+ when = "textInputFocus";
+ }
+ ]
+ '';
+ description = ''
+ Keybindings written to Visual Studio Code's
+ <filename>keybindings.json</filename>.
+ '';
+ };
+
extensions = mkOption {
type = types.listOf types.package;
default = [];
@@ -93,6 +135,10 @@ in
mkIf (cfg.userSettings != {}) {
text = builtins.toJSON cfg.userSettings;
};
+ "${keybindingsFilePath}" =
+ mkIf (cfg.keybindings != []) {
+ text = builtins.toJSON cfg.keybindings;
+ };
}
toSymlink;
};