mirror of
https://github.com/nix-community/home-manager
synced 2024-11-23 11:39:46 +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 {
|
when = mkOption {
|
||||||
type = types.str;
|
type = types.nullOr (types.str);
|
||||||
default = "";
|
default = null;
|
||||||
example = "textInputFocus";
|
example = "textInputFocus";
|
||||||
description = "Optional context filter.";
|
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 = [ ];
|
default = [ ];
|
||||||
|
@ -125,12 +133,14 @@ in {
|
||||||
(k: _: { "${extensionPath}/${k}".source = "${path}/${subDir}/${k}"; })
|
(k: _: { "${extensionPath}/${k}".source = "${path}/${subDir}/${k}"; })
|
||||||
(builtins.readDir (path + "/${subDir}"));
|
(builtins.readDir (path + "/${subDir}"));
|
||||||
toSymlink = concatMap toPaths cfg.extensions;
|
toSymlink = concatMap toPaths cfg.extensions;
|
||||||
|
dropNullFields = filterAttrs (_: v: v != null);
|
||||||
in foldr (a: b: a // b) {
|
in foldr (a: b: a // b) {
|
||||||
"${configFilePath}" = mkIf (cfg.userSettings != { }) {
|
"${configFilePath}" = mkIf (cfg.userSettings != { }) {
|
||||||
source = jsonFormat.generate "vscode-user-settings" cfg.userSettings;
|
source = jsonFormat.generate "vscode-user-settings" cfg.userSettings;
|
||||||
};
|
};
|
||||||
"${keybindingsFilePath}" = mkIf (cfg.keybindings != [ ]) {
|
"${keybindingsFilePath}" = mkIf (cfg.keybindings != [ ]) {
|
||||||
source = jsonFormat.generate "vscode-keybindings" cfg.keybindings;
|
source = jsonFormat.generate "vscode-keybindings"
|
||||||
|
(map dropNullFields cfg.keybindings);
|
||||||
};
|
};
|
||||||
} toSymlink;
|
} toSymlink;
|
||||||
};
|
};
|
||||||
|
|
|
@ -20,6 +20,11 @@ let
|
||||||
command = "deleteFile";
|
command = "deleteFile";
|
||||||
when = "explorerViewletVisible";
|
when = "explorerViewletVisible";
|
||||||
}
|
}
|
||||||
|
{
|
||||||
|
key = "ctrl+r";
|
||||||
|
command = "run";
|
||||||
|
args = { command = "echo file"; };
|
||||||
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
targetPath = if pkgs.stdenv.hostPlatform.isDarwin then
|
targetPath = if pkgs.stdenv.hostPlatform.isDarwin then
|
||||||
|
@ -43,6 +48,13 @@ let
|
||||||
"command": "deleteFile",
|
"command": "deleteFile",
|
||||||
"key": "d",
|
"key": "d",
|
||||||
"when": "explorerViewletVisible"
|
"when": "explorerViewletVisible"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"args": {
|
||||||
|
"command": "echo file"
|
||||||
|
},
|
||||||
|
"command": "run",
|
||||||
|
"key": "ctrl+r"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
'';
|
'';
|
||||||
|
@ -51,18 +63,9 @@ in {
|
||||||
programs.vscode = {
|
programs.vscode = {
|
||||||
enable = true;
|
enable = true;
|
||||||
keybindings = bindings;
|
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 = ''
|
nmt.script = ''
|
||||||
assertFileExists "home-files/${targetPath}"
|
assertFileExists "home-files/${targetPath}"
|
||||||
assertFileContent "home-files/${targetPath}" "${expectedJson}"
|
assertFileContent "home-files/${targetPath}" "${expectedJson}"
|
||||||
|
|
Loading…
Reference in a new issue