vscode: add args option to keybindings

Also make `when` optional.
This commit is contained in:
Jakub Kozłowski 2021-01-30 01:00:58 +01:00 committed by Robert Helgesson
parent 46a750f94f
commit d420287583
No known key found for this signature in database
GPG key ID: 36BDAA14C2797E89
2 changed files with 26 additions and 13 deletions

View file

@ -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;
};