mirror of
https://github.com/nix-community/nixvim.git
synced 2025-07-10 17:24:32 +02:00
modules/highlights: added a wrapper around vim.fn.matchadd (#123)
* modules/highlights: added a wrapper around vim.fn.matchadd * modules/highlights: fix mkIf Co-authored-by: Pedro Alves <pta2002@pta2002.com>
This commit is contained in:
parent
1480ffe201
commit
1022eae161
1 changed files with 26 additions and 3 deletions
|
@ -15,10 +15,21 @@ with lib;
|
||||||
};
|
};
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
match = mkOption {
|
||||||
|
type = types.attrsOf types.str;
|
||||||
|
default = { };
|
||||||
|
description = "Define match groups";
|
||||||
|
example = ''
|
||||||
|
match = {
|
||||||
|
ExtraWhitespace = '\\s\\+$';
|
||||||
|
};
|
||||||
|
'';
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf (config.highlight != { }) {
|
config = mkIf (config.highlight != { } || config.matches != { }) {
|
||||||
extraConfigLuaPost = ''
|
extraConfigLuaPost = (optionalString (config.highlight != { }) ''
|
||||||
-- Highlight groups {{
|
-- Highlight groups {{
|
||||||
do
|
do
|
||||||
local highlights = ${helpers.toLuaObject config.highlight}
|
local highlights = ${helpers.toLuaObject config.highlight}
|
||||||
|
@ -28,6 +39,18 @@ with lib;
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
-- }}
|
-- }}
|
||||||
'';
|
'') ++
|
||||||
|
(optionalString (config.matches != { }) ''
|
||||||
|
-- Match groups {{
|
||||||
|
do
|
||||||
|
local match = ${helpers.toLuaObject config.match}
|
||||||
|
|
||||||
|
for k,v in pairs(match) do
|
||||||
|
vim.fn.matchadd(k, v)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
-- }}
|
||||||
|
'');
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue