2022-11-11 02:15:23 +00:00
|
|
|
{
|
2023-02-20 11:42:13 +01:00
|
|
|
lib,
|
2023-11-06 15:04:08 +01:00
|
|
|
helpers,
|
|
|
|
config,
|
2023-02-20 11:42:13 +01:00
|
|
|
...
|
2023-11-06 15:04:08 +01:00
|
|
|
}:
|
|
|
|
with lib; {
|
|
|
|
options = {
|
|
|
|
highlight = mkOption {
|
2024-01-01 23:47:06 +01:00
|
|
|
type = types.attrsOf helpers.nixvimTypes.highlight;
|
2023-11-06 15:04:08 +01:00
|
|
|
default = {};
|
2024-02-11 12:51:34 +00:00
|
|
|
description = "Define highlight groups.";
|
2023-11-06 15:04:08 +01:00
|
|
|
example = ''
|
|
|
|
highlight = {
|
2023-12-05 11:18:59 +01:00
|
|
|
Comment.fg = "#ff0000";
|
2023-11-06 15:04:08 +01:00
|
|
|
};
|
|
|
|
'';
|
|
|
|
};
|
2023-01-21 18:09:58 +01:00
|
|
|
|
2023-11-06 15:04:08 +01:00
|
|
|
match = mkOption {
|
|
|
|
type = types.attrsOf types.str;
|
|
|
|
default = {};
|
|
|
|
description = "Define match groups";
|
|
|
|
example = ''
|
|
|
|
match = {
|
2023-12-05 11:18:59 +01:00
|
|
|
ExtraWhitespace = "\\s\\+$";
|
2023-11-06 15:04:08 +01:00
|
|
|
};
|
|
|
|
'';
|
2023-01-21 18:09:58 +01:00
|
|
|
};
|
2023-11-06 15:04:08 +01:00
|
|
|
};
|
|
|
|
|
2024-02-09 10:23:04 +01:00
|
|
|
config = {
|
2024-02-04 18:00:50 -06:00
|
|
|
extraConfigLuaPre =
|
2023-11-06 15:04:08 +01:00
|
|
|
(optionalString (config.highlight != {}) ''
|
|
|
|
-- Highlight groups {{
|
|
|
|
do
|
|
|
|
local highlights = ${helpers.toLuaObject config.highlight}
|
2022-11-11 02:15:23 +00:00
|
|
|
|
2023-11-06 15:04:08 +01:00
|
|
|
for k,v in pairs(highlights) do
|
|
|
|
vim.api.nvim_set_hl(0, k, v)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
-- }}
|
|
|
|
'')
|
|
|
|
+ (optionalString (config.match != {}) ''
|
|
|
|
-- Match groups {{
|
2023-02-20 11:42:13 +01:00
|
|
|
do
|
2023-11-06 15:04:08 +01:00
|
|
|
local match = ${helpers.toLuaObject config.match}
|
2022-11-11 02:15:23 +00:00
|
|
|
|
2023-11-06 15:04:08 +01:00
|
|
|
for k,v in pairs(match) do
|
|
|
|
vim.fn.matchadd(k, v)
|
2023-02-20 11:42:13 +01:00
|
|
|
end
|
2023-01-21 18:09:58 +01:00
|
|
|
end
|
2023-02-20 11:42:13 +01:00
|
|
|
-- }}
|
2023-11-06 15:04:08 +01:00
|
|
|
'');
|
|
|
|
};
|
|
|
|
}
|