summaryrefslogtreecommitdiff
path: root/lua/clever_f/feedback_service.lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua/clever_f/feedback_service.lua')
-rw-r--r--lua/clever_f/feedback_service.lua44
1 files changed, 44 insertions, 0 deletions
diff --git a/lua/clever_f/feedback_service.lua b/lua/clever_f/feedback_service.lua
index b1a4233..2b100a4 100644
--- a/lua/clever_f/feedback_service.lua
+++ b/lua/clever_f/feedback_service.lua
@@ -133,6 +133,7 @@ function FeedbackService.new(options)
options.transitions or options.state_transitions,
options.state
),
+ persistent_requests = {},
}
return service
end
@@ -281,6 +282,49 @@ function FeedbackService:remove_temporary_overlay(resource)
return removed
end
+function M.persistent_context_eligible(context)
+ context = domain.ModeContext.from_full_mode(context)
+ return context.key == "n"
+ or context.visual_kind ~= nil
+ or context.select_kind ~= nil
+ or context.key == "cv"
+ or context.key == "cvr"
+end
+
+function FeedbackService:request_persistent(specification)
+ if type(specification) ~= "table" then
+ fail("persistent feedback request must be a table", 2)
+ end
+ local context = domain.ModeContext.from_full_mode(specification.context)
+ if not M.persistent_context_eligible(context) then
+ fail("persistent feedback request requires an eligible context", 2)
+ end
+ if not domain.TargetPlan.is(specification.target_plan) then
+ fail("persistent feedback request requires a TargetPlan", 2)
+ end
+ if not domain.ResolvedMotionPlan.is(specification.motion_plan) then
+ fail("persistent feedback request requires a ResolvedMotionPlan", 2)
+ end
+ local request = {
+ context = context,
+ anchor = domain.Position.coerce(specification.anchor),
+ target_plan = specification.target_plan,
+ motion_plan = specification.motion_plan,
+ window = specification.window,
+ }
+ local requests = service_records[self].persistent_requests
+ requests[#requests + 1] = request
+ return request
+end
+
+function FeedbackService:persistent_requests()
+ local result = {}
+ for index, request in ipairs(service_records[self].persistent_requests) do
+ result[index] = request
+ end
+ return result
+end
+
function FeedbackService:evaluate_feature_links()
local record = service_records[self]
local rules = record.policy:evaluate_highlight_links()