2021-02-04 23:26:00 +01:00
|
|
|
# Test that keybindings.json is created correctly.
|
2020-06-22 20:48:22 +02:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
bindings = [
|
|
|
|
{
|
|
|
|
key = "ctrl+c";
|
|
|
|
command = "editor.action.clipboardCopyAction";
|
|
|
|
when = "textInputFocus && false";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
key = "ctrl+c";
|
|
|
|
command = "deleteFile";
|
|
|
|
when = "";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
key = "d";
|
|
|
|
command = "deleteFile";
|
|
|
|
when = "explorerViewletVisible";
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
|
|
|
targetPath = if pkgs.stdenv.hostPlatform.isDarwin then
|
|
|
|
"Library/Application Support/Code/User/keybindings.json"
|
|
|
|
else
|
|
|
|
".config/Code/User/keybindings.json";
|
|
|
|
|
2020-11-30 03:54:55 +01:00
|
|
|
expectedJson = pkgs.writeText "expected.json" ''
|
|
|
|
[
|
|
|
|
{
|
|
|
|
"command": "editor.action.clipboardCopyAction",
|
|
|
|
"key": "ctrl+c",
|
|
|
|
"when": "textInputFocus && false"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"command": "deleteFile",
|
|
|
|
"key": "ctrl+c",
|
|
|
|
"when": ""
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"command": "deleteFile",
|
|
|
|
"key": "d",
|
|
|
|
"when": "explorerViewletVisible"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
'';
|
2020-06-22 20:48:22 +02:00
|
|
|
in {
|
|
|
|
config = {
|
|
|
|
programs.vscode = {
|
|
|
|
enable = true;
|
|
|
|
keybindings = bindings;
|
|
|
|
};
|
|
|
|
|
|
|
|
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}"
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
}
|