nix-community.nixvim/modules/highlights.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

86 lines
1.9 KiB
Nix
Raw Normal View History

2022-11-11 02:15:23 +00:00
{
lib,
helpers,
config,
...
}:
{
options = {
2024-08-30 14:37:41 -05:00
highlight = lib.mkOption {
2024-09-27 08:07:20 +01:00
type = lib.types.attrsOf lib.types.highlight;
default = { };
description = "Define new highlight groups";
example = {
MacchiatoRed.fg = "#ed8796";
};
};
2024-08-30 14:37:41 -05:00
highlightOverride = lib.mkOption {
2024-09-27 08:07:20 +01:00
type = lib.types.attrsOf lib.types.highlight;
default = { };
description = "Define highlight groups to override existing highlight";
example = {
Comment.fg = "#ff0000";
};
};
2024-08-30 14:37:41 -05:00
match = lib.mkOption {
type = lib.types.attrsOf lib.types.str;
default = { };
description = "Define match groups";
example = {
ExtraWhitespace = "\\s\\+$";
};
};
};
2024-08-30 14:37:41 -05:00
config = lib.mkMerge [
{
extraConfigLuaPre =
2024-08-30 14:37:41 -05:00
lib.mkIf (config.highlight != { })
# lua
''
-- Highlight groups {{
do
local highlights = ${lib.nixvim.toLuaObject config.highlight}
2022-11-11 02:15:23 +00:00
for k,v in pairs(highlights) do
vim.api.nvim_set_hl(0, k, v)
end
end
-- }}
'';
extraConfigLuaPost =
2024-08-30 14:37:41 -05:00
lib.mkIf (config.highlightOverride != { })
# lua
''
-- Highlight groups {{
do
local highlights = ${lib.nixvim.toLuaObject config.highlightOverride}
2022-11-11 02:15:23 +00:00
for k,v in pairs(highlights) do
vim.api.nvim_set_hl(0, k, v)
end
end
-- }}
'';
}
{
extraConfigLuaPre =
2024-08-30 14:37:41 -05:00
lib.mkIf (config.match != { })
# lua
''
-- Match groups {{
do
local match = ${lib.nixvim.toLuaObject config.match}
for k,v in pairs(match) do
vim.fn.matchadd(k, v)
end
2024-05-05 19:39:35 +02:00
end
-- }}
'';
}
];
}