summaryrefslogtreecommitdiff
path: root/lua/clever_f/testing/memory_host.lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua/clever_f/testing/memory_host.lua')
-rw-r--r--lua/clever_f/testing/memory_host.lua32
1 files changed, 32 insertions, 0 deletions
diff --git a/lua/clever_f/testing/memory_host.lua b/lua/clever_f/testing/memory_host.lua
index 459c9a8..0f8fc2d 100644
--- a/lua/clever_f/testing/memory_host.lua
+++ b/lua/clever_f/testing/memory_host.lua
@@ -663,6 +663,38 @@ function MemoryHost:highlight_groups()
return copy(self._highlight_groups)
end
+function MemoryHost:define_highlight_group(name, definition, options)
+ if type(name) ~= "string" or name == "" then
+ error("highlight group name must be a nonempty string", 2)
+ end
+ if type(definition) ~= "table" then
+ error("highlight group definition must be a table", 2)
+ end
+ options = options or {}
+ if type(options) ~= "table" then
+ error("highlight group options must be a table", 2)
+ end
+ if options.default ~= nil and type(options.default) ~= "boolean" then
+ error("highlight group default option must be a Boolean", 2)
+ end
+ if options.force ~= nil and type(options.force) ~= "boolean" then
+ error("highlight group force option must be a Boolean", 2)
+ end
+
+ local exists = self._highlight_groups[name] ~= nil
+ local applied = not (exists and options.default)
+ if applied then
+ self._highlight_groups[name] = copy(definition)
+ end
+ self:_record("define_highlight_group", {
+ name = name,
+ definition = definition,
+ options = options,
+ applied = applied,
+ })
+ return applied
+end
+
function MemoryHost:create_highlight(specification)
if type(specification) ~= "table" then
error("highlight specification must be a table", 2)