mirror of
https://github.com/nix-community/home-manager
synced 2024-12-23 18:29:47 +01:00
vscode: add args
option to keybindings
Also make `when` optional.
This commit is contained in:
parent
46a750f94f
commit
d420287583
2 changed files with 26 additions and 13 deletions
|
@ -78,11 +78,19 @@ in {
|
|||
};
|
||||
|
||||
when = mkOption {
|
||||
type = types.str;
|
||||
default = "";
|
||||
type = types.nullOr (types.str);
|
||||
default = null;
|
||||
example = "textInputFocus";
|
||||
description = "Optional context filter.";
|
||||
};
|
||||
|
||||
# https://code.visualstudio.com/docs/getstarted/keybindings#_command-arguments
|
||||
args = mkOption {
|
||||
type = types.nullOr (types.attrs);
|
||||
default = null;
|
||||
example = { direction = "up"; };
|
||||
description = "Optional arguments for a command.";
|
||||
};
|
||||
};
|
||||
});
|
||||
default = [ ];
|
||||
|
@ -125,12 +133,14 @@ in {
|
|||
(k: _: { "${extensionPath}/${k}".source = "${path}/${subDir}/${k}"; })
|
||||
(builtins.readDir (path + "/${subDir}"));
|
||||
toSymlink = concatMap toPaths cfg.extensions;
|
||||
dropNullFields = filterAttrs (_: v: v != null);
|
||||
in foldr (a: b: a // b) {
|
||||
"${configFilePath}" = mkIf (cfg.userSettings != { }) {
|
||||
source = jsonFormat.generate "vscode-user-settings" cfg.userSettings;
|
||||
};
|
||||
"${keybindingsFilePath}" = mkIf (cfg.keybindings != [ ]) {
|
||||
source = jsonFormat.generate "vscode-keybindings" cfg.keybindings;
|
||||
source = jsonFormat.generate "vscode-keybindings"
|
||||
(map dropNullFields cfg.keybindings);
|
||||
};
|
||||
} toSymlink;
|
||||
};
|
||||
|
|
|
@ -20,6 +20,11 @@ let
|
|||
command = "deleteFile";
|
||||
when = "explorerViewletVisible";
|
||||
}
|
||||
{
|
||||
key = "ctrl+r";
|
||||
command = "run";
|
||||
args = { command = "echo file"; };
|
||||
}
|
||||
];
|
||||
|
||||
targetPath = if pkgs.stdenv.hostPlatform.isDarwin then
|
||||
|
@ -43,6 +48,13 @@ let
|
|||
"command": "deleteFile",
|
||||
"key": "d",
|
||||
"when": "explorerViewletVisible"
|
||||
},
|
||||
{
|
||||
"args": {
|
||||
"command": "echo file"
|
||||
},
|
||||
"command": "run",
|
||||
"key": "ctrl+r"
|
||||
}
|
||||
]
|
||||
'';
|
||||
|
@ -51,18 +63,9 @@ in {
|
|||
programs.vscode = {
|
||||
enable = true;
|
||||
keybindings = bindings;
|
||||
package = pkgs.writeScriptBin "vscode" "" // { pname = "vscode"; };
|
||||
};
|
||||
|
||||
nixpkgs.overlays = [
|
||||
(self: super: {
|
||||
vscode = pkgs.runCommandLocal "vscode" { pname = "vscode"; } ''
|
||||
mkdir -p $out/bin
|
||||
touch $out/bin/code
|
||||
chmod +x $out/bin/code;
|
||||
'';
|
||||
})
|
||||
];
|
||||
|
||||
nmt.script = ''
|
||||
assertFileExists "home-files/${targetPath}"
|
||||
assertFileContent "home-files/${targetPath}" "${expectedJson}"
|
||||
|
|
Loading…
Reference in a new issue