Improved AI tools
This commit is contained in:
53
lua/utils/fidget_helper.lua
Normal file
53
lua/utils/fidget_helper.lua
Normal file
@@ -0,0 +1,53 @@
|
||||
local progress = require 'fidget.progress'
|
||||
local M = {}
|
||||
|
||||
M.handles = {}
|
||||
|
||||
function M:store_progress_handle(id, handle)
|
||||
M.handles[id] = handle
|
||||
end
|
||||
|
||||
function M:pop_progress_handle(id)
|
||||
local handle = M.handles[id]
|
||||
M.handles[id] = nil
|
||||
return handle
|
||||
end
|
||||
|
||||
function M:create_progress_handle(request)
|
||||
-- Ensure request.data and request.data.adapter exist before accessing them
|
||||
local strategy = request.data and request.data.strategy or 'unknown'
|
||||
local adapter_info = request.data and request.data.adapter or {}
|
||||
|
||||
return progress.handle.create {
|
||||
title = ' Requesting assistance (' .. strategy .. ')',
|
||||
message = 'In progress...',
|
||||
lsp_client = {
|
||||
name = M:llm_role_title(adapter_info),
|
||||
},
|
||||
}
|
||||
end
|
||||
|
||||
function M:llm_role_title(adapter)
|
||||
local parts = {}
|
||||
-- Use adapter.formatted_name if available, otherwise default
|
||||
local name = adapter.formatted_name or 'LLM'
|
||||
table.insert(parts, name)
|
||||
if adapter.model and adapter.model ~= '' then
|
||||
table.insert(parts, '(' .. adapter.model .. ')')
|
||||
end
|
||||
return table.concat(parts, ' ')
|
||||
end
|
||||
|
||||
function M:report_exit_status(handle, request)
|
||||
-- Ensure request.data exists before accessing status
|
||||
local status = request.data and request.data.status or 'unknown'
|
||||
if status == 'success' then
|
||||
handle.message = 'Completed'
|
||||
elseif status == 'error' then
|
||||
handle.message = ' Error'
|
||||
else -- Includes "cancelled" or any other status
|
||||
handle.message = ' Cancelled/Other'
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
||||
Reference in New Issue
Block a user