47 lines
1.3 KiB
Nix
47 lines
1.3 KiB
Nix
|
{ config, pkgs, lib, ... }:
|
||
|
|
||
|
let
|
||
|
cfg = config.programs.helix;
|
||
|
tomlFormat = pkgs.formats.toml { };
|
||
|
inherit (lib) mkIf mkEnableOption mkOption types;
|
||
|
in {
|
||
|
options.programs.helix = {
|
||
|
autoTheme.enable =
|
||
|
mkEnableOption "Automatically switch helix theme with night mode";
|
||
|
|
||
|
autoTheme.light = mkOption {
|
||
|
type = types.str;
|
||
|
description = "Light mode theme";
|
||
|
};
|
||
|
|
||
|
autoTheme.dark = mkOption {
|
||
|
type = types.str;
|
||
|
description = "Dark mode theme";
|
||
|
};
|
||
|
};
|
||
|
|
||
|
config = mkIf (cfg.enable && cfg.autoTheme.enable) {
|
||
|
xdg.configFile = {
|
||
|
"helix/light.toml".source = tomlFormat.generate "helix-autotheme"
|
||
|
(cfg.settings // { theme = cfg.autoTheme.light; });
|
||
|
"helix/dark.toml".source = tomlFormat.generate "helix-autotheme"
|
||
|
(cfg.settings // { theme = cfg.autoTheme.dark; });
|
||
|
};
|
||
|
|
||
|
programs.fish.functions = {
|
||
|
hx = {
|
||
|
wraps = "hx";
|
||
|
description =
|
||
|
"Helix invocation wrapper to automatically select the right theme";
|
||
|
body = ''
|
||
|
if is-dark-mode
|
||
|
command hx --config ${config.xdg.configHome}/helix/dark.toml $argv
|
||
|
else
|
||
|
command hx --config ${config.xdg.configHome}/helix/light.toml $argv
|
||
|
end
|
||
|
'';
|
||
|
};
|
||
|
};
|
||
|
};
|
||
|
}
|