sioyek: enable multiple bindings for the same command
This commit is contained in:
parent
3b5a8d3dc7
commit
bd87a34bb4
|
@ -1,11 +1,16 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
|
||||
cfg = config.programs.sioyek;
|
||||
|
||||
renderAttrs = attrs:
|
||||
concatStringsSep "\n"
|
||||
(mapAttrsToList (name: value: "${name} ${value}") attrs);
|
||||
renderConfig = generators.toKeyValue {
|
||||
mkKeyValue = key: value: "${key} ${value}";
|
||||
listsAsDuplicateKeys = true;
|
||||
};
|
||||
|
||||
in {
|
||||
options = {
|
||||
programs.sioyek = {
|
||||
|
@ -24,8 +29,11 @@ in {
|
|||
Input configuration written to
|
||||
<filename>$XDG_CONFIG_HOME/sioyek/keys_user.config</filename>.
|
||||
See <link xlink:href="https://github.com/ahrm/sioyek/blob/main/pdf_viewer/keys.config"/>.
|
||||
</para><para>
|
||||
Each attribute could also accept a list of strings to set multiple
|
||||
bindings of the same command.
|
||||
'';
|
||||
type = types.attrsOf types.str;
|
||||
type = with types; attrsOf (either str (listOf str));
|
||||
default = { };
|
||||
example = literalExpression ''
|
||||
{
|
||||
|
@ -33,6 +41,8 @@ in {
|
|||
"move_down" = "j";
|
||||
"move_left" = "h";
|
||||
"move_right" = "l";
|
||||
"screen_down" = [ "d" "<C-d>" ];
|
||||
"screen_up" = [ "u" "<C-u>" ];
|
||||
}
|
||||
'';
|
||||
};
|
||||
|
@ -59,10 +69,10 @@ in {
|
|||
config = mkIf cfg.enable (mkMerge [
|
||||
{ home.packages = [ cfg.package ]; }
|
||||
(mkIf (cfg.config != { }) {
|
||||
xdg.configFile."sioyek/prefs_user.config".text = renderAttrs cfg.config;
|
||||
xdg.configFile."sioyek/prefs_user.config".text = renderConfig cfg.config;
|
||||
})
|
||||
(mkIf (cfg.bindings != { }) {
|
||||
xdg.configFile."sioyek/keys_user.config".text = renderAttrs cfg.bindings;
|
||||
xdg.configFile."sioyek/keys_user.config".text = renderConfig cfg.bindings;
|
||||
})
|
||||
]);
|
||||
|
||||
|
|
|
@ -110,6 +110,7 @@ import nmt {
|
|||
./modules/programs/sagemath
|
||||
./modules/programs/sbt
|
||||
./modules/programs/scmpuff
|
||||
./modules/programs/sioyek
|
||||
./modules/programs/sm64ex
|
||||
./modules/programs/ssh
|
||||
./modules/programs/starship
|
||||
|
|
1
tests/modules/programs/sioyek/default.nix
Normal file
1
tests/modules/programs/sioyek/default.nix
Normal file
|
@ -0,0 +1 @@
|
|||
{ sioyek = ./sioyek-basic-configuration.nix; }
|
36
tests/modules/programs/sioyek/sioyek-basic-configuration.nix
Normal file
36
tests/modules/programs/sioyek/sioyek-basic-configuration.nix
Normal file
|
@ -0,0 +1,36 @@
|
|||
{ config, pkgs, ... }:
|
||||
|
||||
{
|
||||
programs.sioyek = {
|
||||
enable = true;
|
||||
bindings = {
|
||||
"move_down" = "j";
|
||||
"move_left" = "h";
|
||||
"move_right" = "l";
|
||||
"move_up" = "k";
|
||||
"screen_down" = [ "d" "<C-d>" ];
|
||||
"screen_up" = [ "u" "<C-u>" ];
|
||||
};
|
||||
config = {
|
||||
"dark_mode_background_color" = "0.0 0.0 0.0";
|
||||
"dark_mode_contrast" = "0.8";
|
||||
};
|
||||
};
|
||||
|
||||
test.stubs.sioyek = { };
|
||||
|
||||
nmt = {
|
||||
description = "Sioyek basic setup with sample configuration";
|
||||
script = ''
|
||||
assertFileExists home-files/.config/sioyek/prefs_user.config
|
||||
assertFileContent home-files/.config/sioyek/prefs_user.config ${
|
||||
./test_prefs_user.config
|
||||
}
|
||||
|
||||
assertFileExists home-files/.config/sioyek/keys_user.config
|
||||
assertFileContent home-files/.config/sioyek/keys_user.config ${
|
||||
./test_keys_user.config
|
||||
}
|
||||
'';
|
||||
};
|
||||
}
|
8
tests/modules/programs/sioyek/test_keys_user.config
Normal file
8
tests/modules/programs/sioyek/test_keys_user.config
Normal file
|
@ -0,0 +1,8 @@
|
|||
move_down j
|
||||
move_left h
|
||||
move_right l
|
||||
move_up k
|
||||
screen_down d
|
||||
screen_down <C-d>
|
||||
screen_up u
|
||||
screen_up <C-u>
|
2
tests/modules/programs/sioyek/test_prefs_user.config
Normal file
2
tests/modules/programs/sioyek/test_prefs_user.config
Normal file
|
@ -0,0 +1,2 @@
|
|||
dark_mode_background_color 0.0 0.0 0.0
|
||||
dark_mode_contrast 0.8
|
Loading…
Reference in a new issue