From 753f248eb30350eb9ba6ca108e466be8e54a51c8 Mon Sep 17 00:00:00 2001 From: Jackson Moore Date: Fri, 4 Sep 2026 11:35:32 +0200 Subject: Apply missing default label fallback --- lua/clever_f/capabilities.lua | 6 +++++- lua/clever_f/feedback_service.lua | 19 +++++++++++++++++-- lua/clever_f/testing/memory_host.lua | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+), 3 deletions(-) (limited to 'lua/clever_f') diff --git a/lua/clever_f/capabilities.lua b/lua/clever_f/capabilities.lua index 194de0b..3e770bd 100644 --- a/lua/clever_f/capabilities.lua +++ b/lua/clever_f/capabilities.lua @@ -22,7 +22,11 @@ M.effect_methods = { prompt = { "show_prompt" }, redraw = { "redraw" }, diagnostics = { "emit_diagnostic" }, - highlights = { "create_highlight", "remove_highlight" }, + highlights = { + "define_highlight_group", + "create_highlight", + "remove_highlight", + }, cursor_presentation = { "suppress_cursor_presentation", "restore_cursor_presentation", diff --git a/lua/clever_f/feedback_service.lua b/lua/clever_f/feedback_service.lua index f7e1dd6..d1fa9d6 100644 --- a/lua/clever_f/feedback_service.lua +++ b/lua/clever_f/feedback_service.lua @@ -52,7 +52,10 @@ local function normalize_options(options) end local function require_host(host) - if type(host) ~= "table" or type(host.read_highlight_group) ~= "function" then + if type(host) ~= "table" + or type(host.read_highlight_group) ~= "function" + or type(host.define_highlight_group) ~= "function" + then fail("FeedbackService host must provide highlight groups", 3) end return host @@ -86,7 +89,19 @@ function FeedbackService:ensure_default_label() applied = false, } end - return nil + + local definition = M.default_label_definition() + service_records[self].host:define_highlight_group( + M.DEFAULT_LABEL_GROUP, + definition, + { default = true } + ) + return { + group = M.DEFAULT_LABEL_GROUP, + definition = definition, + source = "fallback", + applied = true, + } end function M.new(options) 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) -- cgit v1.2.3