Skip to content

Commit

Permalink
modules/highlights: added a wrapper around vim.fn.matchadd (nix-commu…
Browse files Browse the repository at this point in the history
…nity#123)

* modules/highlights: added a wrapper around vim.fn.matchadd

* modules/highlights: fix mkIf

Co-authored-by: Pedro Alves <pta2002@pta2002.com>
  • Loading branch information
GaetanLepage and pta2002 authored Jan 21, 2023
1 parent 1480ffe commit 1022eae
Showing 1 changed file with 26 additions and 3 deletions.
29 changes: 26 additions & 3 deletions modules/highlights.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -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
-- }}
'');
};
}

0 comments on commit 1022eae

Please sign in to comment.