2021-07-02 22:36:30 +00:00
|
|
|
# Test that keybindings.json is created correctly.
|
2023-08-08 10:19:01 +00:00
|
|
|
{ pkgs, ... }:
|
2020-10-12 00:22:58 +00:00
|
|
|
|
|
|
|
let
|
|
|
|
bindings = [
|
|
|
|
{
|
|
|
|
key = "ctrl+c";
|
|
|
|
command = "editor.action.clipboardCopyAction";
|
|
|
|
when = "textInputFocus && false";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
key = "ctrl+c";
|
|
|
|
command = "deleteFile";
|
|
|
|
when = "";
|
|
|
|
}
|
|
|
|
{
|
|
|
|
key = "d";
|
|
|
|
command = "deleteFile";
|
|
|
|
when = "explorerViewletVisible";
|
|
|
|
}
|
2021-07-02 22:36:30 +00:00
|
|
|
{
|
|
|
|
key = "ctrl+r";
|
|
|
|
command = "run";
|
|
|
|
args = { command = "echo file"; };
|
|
|
|
}
|
2020-10-12 00:22:58 +00:00
|
|
|
];
|
|
|
|
|
2023-01-10 09:35:00 +00:00
|
|
|
keybindingsPath = if pkgs.stdenv.hostPlatform.isDarwin then
|
2020-10-12 00:22:58 +00:00
|
|
|
"Library/Application Support/Code/User/keybindings.json"
|
|
|
|
else
|
|
|
|
".config/Code/User/keybindings.json";
|
|
|
|
|
2023-01-10 09:35:00 +00:00
|
|
|
settingsPath = if pkgs.stdenv.hostPlatform.isDarwin then
|
|
|
|
"Library/Application Support/Code/User/settings.json"
|
|
|
|
else
|
|
|
|
".config/Code/User/settings.json";
|
|
|
|
|
|
|
|
expectedKeybindings = pkgs.writeText "expected.json" ''
|
2021-07-02 22:36:30 +00:00
|
|
|
[
|
|
|
|
{
|
|
|
|
"command": "editor.action.clipboardCopyAction",
|
|
|
|
"key": "ctrl+c",
|
|
|
|
"when": "textInputFocus && false"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"command": "deleteFile",
|
|
|
|
"key": "ctrl+c",
|
|
|
|
"when": ""
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"command": "deleteFile",
|
|
|
|
"key": "d",
|
|
|
|
"when": "explorerViewletVisible"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"args": {
|
|
|
|
"command": "echo file"
|
|
|
|
},
|
|
|
|
"command": "run",
|
|
|
|
"key": "ctrl+r"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
'';
|
2023-01-10 09:35:00 +00:00
|
|
|
|
2020-10-12 00:22:58 +00:00
|
|
|
in {
|
2023-08-08 10:19:01 +00:00
|
|
|
programs.vscode = {
|
|
|
|
enable = true;
|
|
|
|
keybindings = bindings;
|
|
|
|
package = pkgs.writeScriptBin "vscode" "" // { pname = "vscode"; };
|
|
|
|
};
|
2020-10-12 00:22:58 +00:00
|
|
|
|
2023-08-08 10:19:01 +00:00
|
|
|
nmt.script = ''
|
|
|
|
assertFileExists "home-files/${keybindingsPath}"
|
|
|
|
assertFileContent "home-files/${keybindingsPath}" "${expectedKeybindings}"
|
2023-01-10 09:35:00 +00:00
|
|
|
|
2023-08-08 10:19:01 +00:00
|
|
|
assertPathNotExists "home-files/${settingsPath}"
|
|
|
|
'';
|
2020-10-12 00:22:58 +00:00
|
|
|
}
|