mirror of
https://github.com/nix-community/home-manager
synced 2024-12-26 03:39:47 +01:00
bat: allow adding custom syntaxes
Adds an option to add custom syntax files to bat's cache, analogous to the existing programs.bat.themes option.
This commit is contained in:
parent
0014d234b3
commit
088f23f690
2 changed files with 33 additions and 1 deletions
|
@ -60,6 +60,24 @@ in {
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
syntaxes = mkOption {
|
||||||
|
type = types.attrsOf types.lines;
|
||||||
|
default = { };
|
||||||
|
example = literalExpression ''
|
||||||
|
{
|
||||||
|
syntaxes.gleam = builtins.readFile (pkgs.fetchFromGitHub {
|
||||||
|
owner = "molnarmark";
|
||||||
|
repo = "sublime-gleam";
|
||||||
|
rev = "2e761cdb1a87539d827987f997a20a35efd68aa9";
|
||||||
|
hash = "sha256-Zj2DKTcO1t9g18qsNKtpHKElbRSc9nBRE2QBzRn9+qs=";
|
||||||
|
} + "/syntax/gleam.sublime-syntax");
|
||||||
|
}
|
||||||
|
'';
|
||||||
|
description = ''
|
||||||
|
Additional syntaxes to provide.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
|
@ -69,7 +87,10 @@ in {
|
||||||
"bat/config" =
|
"bat/config" =
|
||||||
mkIf (cfg.config != { }) { text = toConfigFile cfg.config; };
|
mkIf (cfg.config != { }) { text = toConfigFile cfg.config; };
|
||||||
}] ++ flip mapAttrsToList cfg.themes
|
}] ++ flip mapAttrsToList cfg.themes
|
||||||
(name: body: { "bat/themes/${name}.tmTheme" = { text = body; }; }));
|
(name: body: { "bat/themes/${name}.tmTheme" = { text = body; }; })
|
||||||
|
++ flip mapAttrsToList cfg.syntaxes (name: body: {
|
||||||
|
"bat/syntaxes/${name}.sublime-syntax" = { text = body; };
|
||||||
|
}));
|
||||||
|
|
||||||
home.activation.batCache = hm.dag.entryAfter [ "linkGeneration" ] ''
|
home.activation.batCache = hm.dag.entryAfter [ "linkGeneration" ] ''
|
||||||
(
|
(
|
||||||
|
|
|
@ -16,6 +16,10 @@ with lib;
|
||||||
themes.testtheme = ''
|
themes.testtheme = ''
|
||||||
This is a test theme.
|
This is a test theme.
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
syntaxes.testsyntax = ''
|
||||||
|
This is a test syntax.
|
||||||
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
test.stubs.bat = { };
|
test.stubs.bat = { };
|
||||||
|
@ -37,6 +41,13 @@ with lib;
|
||||||
This is a test theme.
|
This is a test theme.
|
||||||
''
|
''
|
||||||
}
|
}
|
||||||
|
|
||||||
|
assertFileExists home-files/.config/bat/syntaxes/testsyntax.sublime-syntax
|
||||||
|
assertFileContent home-files/.config/bat/syntaxes/testsyntax.sublime-syntax ${
|
||||||
|
pkgs.writeText "bat.expected" ''
|
||||||
|
This is a test syntax.
|
||||||
|
''
|
||||||
|
}
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue