diff --git a/modules/highlights.nix b/modules/highlights.nix index 0f5fc1f0..0c6c473a 100644 --- a/modules/highlights.nix +++ b/modules/highlights.nix @@ -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 != { }) { - extraConfigLuaPost = '' + config = mkIf (config.highlight != { } || config.matches != { }) { + extraConfigLuaPost = (optionalString (config.highlight != { }) '' -- Highlight groups {{ do local highlights = ${helpers.toLuaObject config.highlight} @@ -28,6 +39,18 @@ with lib; 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 + -- }} + ''); }; } +