1
0
Fork 0
mirror of https://github.com/nix-community/nixvim.git synced 2025-11-08 11:36:07 +01:00
nixvim/modules/highlights.nix
Matt Sturgeon fe059cd395 flake: add nixf-diagnose to treefmt config
Checks nixd's diagnostic lints using libnixf.
2025-10-01 00:42:40 +00:00

80 lines
1.9 KiB
Nix

{ lib, config, ... }:
{
options = {
highlight = lib.mkOption {
type = lib.types.attrsOf lib.types.highlight;
default = { };
description = "Define new highlight groups";
example = {
MacchiatoRed.fg = "#ed8796";
};
};
highlightOverride = lib.mkOption {
type = lib.types.attrsOf lib.types.highlight;
default = { };
description = "Define highlight groups to override existing highlight";
example = {
Comment.fg = "#ff0000";
};
};
match = lib.mkOption {
type = lib.types.attrsOf lib.types.str;
default = { };
description = "Define match groups";
example = {
ExtraWhitespace = "\\s\\+$";
};
};
};
config = lib.mkMerge [
{
extraConfigLuaPre =
lib.mkIf (config.highlight != { })
# lua
''
-- Highlight groups {{
do
local highlights = ${lib.nixvim.toLuaObject config.highlight}
for k,v in pairs(highlights) do
vim.api.nvim_set_hl(0, k, v)
end
end
-- }}
'';
extraConfigLuaPost =
lib.mkIf (config.highlightOverride != { })
# lua
''
-- Highlight groups {{
do
local highlights = ${lib.nixvim.toLuaObject config.highlightOverride}
for k,v in pairs(highlights) do
vim.api.nvim_set_hl(0, k, v)
end
end
-- }}
'';
}
{
extraConfigLuaPre =
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
end
-- }}
'';
}
];
}