mirror of
https://github.com/nix-community/home-manager
synced 2024-11-10 07:04:17 +00:00
zellij: Add extraConfig option
Mostly useful as a bridge to set keybinds until an idiomatic way has been implemented
This commit is contained in:
parent
d9b88b4352
commit
4dda6397d8
3 changed files with 98 additions and 7 deletions
|
@ -51,6 +51,39 @@ in {
|
|||
enableFishIntegration = mkEnableOption "Fish integration" // {
|
||||
default = false;
|
||||
};
|
||||
|
||||
extraConfig = mkOption {
|
||||
type = lib.types.lines;
|
||||
default = "";
|
||||
example = ''
|
||||
keybinds {
|
||||
// keybinds are divided into modes
|
||||
normal {
|
||||
// bind instructions can include one or more keys (both keys will be bound separately)
|
||||
// bind keys can include one or more actions (all actions will be performed with no sequential guarantees)
|
||||
bind "Ctrl g" { SwitchToMode "locked"; }
|
||||
bind "Ctrl p" { SwitchToMode "pane"; }
|
||||
bind "Alt n" { NewPane; }
|
||||
bind "Alt h" "Alt Left" { MoveFocusOrTab "Left"; }
|
||||
}
|
||||
pane {
|
||||
bind "h" "Left" { MoveFocus "Left"; }
|
||||
bind "l" "Right" { MoveFocus "Right"; }
|
||||
bind "j" "Down" { MoveFocus "Down"; }
|
||||
bind "k" "Up" { MoveFocus "Up"; }
|
||||
bind "p" { SwitchFocus; }
|
||||
}
|
||||
locked {
|
||||
bind "Ctrl g" { SwitchToMode "normal"; }
|
||||
}
|
||||
}
|
||||
'';
|
||||
description = ''
|
||||
Extra configuration lines
|
||||
Versions prior to 0.32.0 use Yaml
|
||||
Versions after 0.32.0 use KDL
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
|
@ -59,14 +92,28 @@ in {
|
|||
# Zellij switched from yaml to KDL in version 0.32.0:
|
||||
# https://github.com/zellij-org/zellij/releases/tag/v0.32.0
|
||||
xdg.configFile."zellij/config.yaml" = mkIf
|
||||
(cfg.settings != { } && (versionOlder cfg.package.version "0.32.0")) {
|
||||
source = yamlFormat.generate "zellij.yaml" cfg.settings;
|
||||
};
|
||||
((cfg.settings != { } || cfg.extraConfig != "")
|
||||
&& (versionOlder cfg.package.version "0.32.0")) {
|
||||
source =
|
||||
let settings = yamlFormat.generate "zellij.yaml" cfg.settings;
|
||||
in ''
|
||||
${settings}
|
||||
|
||||
${cfg.extraConfig}
|
||||
'';
|
||||
};
|
||||
|
||||
xdg.configFile."zellij/config.kdl" = mkIf
|
||||
(cfg.settings != { } && (versionAtLeast cfg.package.version "0.32.0")) {
|
||||
text = lib.hm.generators.toKDL { } cfg.settings;
|
||||
};
|
||||
((cfg.settings != { } || cfg.extraConfig != "")
|
||||
&& (versionAtLeast cfg.package.version "0.32.0")) {
|
||||
text = let settings = lib.hm.generators.toKDL { } cfg.settings;
|
||||
in ''
|
||||
${settings}
|
||||
|
||||
${cfg.extraConfig}
|
||||
'';
|
||||
|
||||
};
|
||||
|
||||
programs.bash.initExtra = mkIf cfg.enableBashIntegration (mkOrder 200 ''
|
||||
eval "$(zellij setup --generate-auto-start bash)"
|
||||
|
|
|
@ -1 +1,4 @@
|
|||
{ zellij-enable-shells = ./enable-shells.nix; }
|
||||
{
|
||||
zellij-enable-shells = ./enable-shells.nix;
|
||||
zellij-extra-config = ./extra-config.nix;
|
||||
}
|
||||
|
|
41
tests/modules/programs/zellij/extra-config.nix
Normal file
41
tests/modules/programs/zellij/extra-config.nix
Normal file
|
@ -0,0 +1,41 @@
|
|||
{ lib, ... }:
|
||||
|
||||
let
|
||||
testInput = ''
|
||||
keybinds {
|
||||
// keybinds are divided into modes
|
||||
normal {
|
||||
// bind instructions can include one or more keys (both keys will be bound separately)
|
||||
// bind keys can include one or more actions (all actions will be performed with no sequential guarantees)
|
||||
bind "Ctrl g" { SwitchToMode "locked"; }
|
||||
bind "Ctrl p" { SwitchToMode "pane"; }
|
||||
bind "Alt n" { NewPane; }
|
||||
bind "Alt h" "Alt Left" { MoveFocusOrTab "Left"; }
|
||||
}
|
||||
pane {
|
||||
bind "h" "Left" { MoveFocus "Left"; }
|
||||
bind "l" "Right" { MoveFocus "Right"; }
|
||||
bind "j" "Down" { MoveFocus "Down"; }
|
||||
bind "k" "Up" { MoveFocus "Up"; }
|
||||
bind "p" { SwitchFocus; }
|
||||
}
|
||||
locked {
|
||||
bind "Ctrl g" { SwitchToMode "normal"; }
|
||||
}
|
||||
}
|
||||
'';
|
||||
in {
|
||||
programs = {
|
||||
zellij = {
|
||||
enable = true;
|
||||
extraConfig = testInput;
|
||||
};
|
||||
};
|
||||
|
||||
nmt.script = ''
|
||||
assertFileExists home-files/.config/zellij/config.kdl
|
||||
assertFileContains \
|
||||
home-files/.config/zellij/config.kdl \
|
||||
"${testInput}"
|
||||
'';
|
||||
}
|
Loading…
Reference in a new issue