vscode: add options for keybindings
Adds a new `keybindings` option to the `vscode` configuration. It contains a list of key bindings, which will be written to `%vscode-dir%/User/keybindings.json`. PR #1351
This commit is contained in:
parent
e6e49ad73c
commit
1ed8e7ef98
4 changed files with 104 additions and 3 deletions
1
tests/modules/programs/vscode/default.nix
Normal file
1
tests/modules/programs/vscode/default.nix
Normal file
|
|
@ -0,0 +1 @@
|
|||
{ vscode-keybindings = ./keybindings.nix; }
|
||||
53
tests/modules/programs/vscode/keybindings.nix
Normal file
53
tests/modules/programs/vscode/keybindings.nix
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
# Test that keybdinings.json is created correctly.
|
||||
{ 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";
|
||||
|
||||
expectedJson = pkgs.writeText "expected.json" (builtins.toJSON bindings);
|
||||
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}"
|
||||
'';
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue