summaryrefslogtreecommitdiff
path: root/lua/clever_f
diff options
context:
space:
mode:
authorJackson Moore <jacksonmoore@tuta.io>2026-09-04 11:35:32 +0200
committerJackson Moore <jacksonmoore@tuta.io>2026-09-04 11:35:32 +0200
commit753f248eb30350eb9ba6ca108e466be8e54a51c8 (patch)
tree373abf23474eb6276432686a76d5154639363948 /lua/clever_f
parent0809f1eb0c73648cae15806cf8a43ad35f445f7c (diff)
Apply missing default label fallback
Diffstat (limited to 'lua/clever_f')
-rw-r--r--lua/clever_f/capabilities.lua6
-rw-r--r--lua/clever_f/feedback_service.lua19
-rw-r--r--lua/clever_f/testing/memory_host.lua32
3 files changed, 54 insertions, 3 deletions
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)