2022-12-29 17:34:47 +00:00
|
|
|
{ config, lib, ... }:
|
|
|
|
let
|
|
|
|
helpers = import ../plugins/helpers.nix { inherit lib; };
|
|
|
|
in
|
2022-11-11 02:15:23 +00:00
|
|
|
with lib;
|
|
|
|
{
|
|
|
|
options = {
|
|
|
|
highlight = mkOption {
|
|
|
|
type = types.attrsOf types.anything;
|
|
|
|
default = { };
|
|
|
|
description = "Define highlight groups";
|
|
|
|
example = ''
|
|
|
|
highlight = {
|
|
|
|
Comment.fg = '#ff0000';
|
|
|
|
};
|
|
|
|
'';
|
|
|
|
};
|
2023-01-21 18:09:58 +01:00
|
|
|
|
|
|
|
match = mkOption {
|
|
|
|
type = types.attrsOf types.str;
|
|
|
|
default = { };
|
|
|
|
description = "Define match groups";
|
|
|
|
example = ''
|
|
|
|
match = {
|
|
|
|
ExtraWhitespace = '\\s\\+$';
|
|
|
|
};
|
|
|
|
'';
|
|
|
|
};
|
2022-11-11 02:15:23 +00:00
|
|
|
};
|
|
|
|
|
2023-01-21 17:21:12 +00:00
|
|
|
config = mkIf (config.highlight != { } || config.match != { }) {
|
2023-01-21 18:09:58 +01:00
|
|
|
extraConfigLuaPost = (optionalString (config.highlight != { }) ''
|
2022-11-11 02:15:23 +00:00
|
|
|
-- Highlight groups {{
|
|
|
|
do
|
|
|
|
local highlights = ${helpers.toLuaObject config.highlight}
|
|
|
|
|
|
|
|
for k,v in pairs(highlights) do
|
|
|
|
vim.api.nvim_set_hl(0, k, v)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
-- }}
|
2023-01-22 13:41:24 +01:00
|
|
|
'') +
|
2023-01-21 17:21:12 +00:00
|
|
|
(optionalString (config.match != { }) ''
|
2023-01-21 18:09:58 +01:00
|
|
|
-- Match groups {{
|
|
|
|
do
|
|
|
|
local match = ${helpers.toLuaObject config.match}
|
|
|
|
|
|
|
|
for k,v in pairs(match) do
|
|
|
|
vim.fn.matchadd(k, v)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
-- }}
|
|
|
|
'');
|
2022-11-11 02:15:23 +00:00
|
|
|
};
|
|
|
|
}
|
2023-01-21 18:09:58 +01:00
|
|
|
|