mirror of
https://github.com/ksyasuda/dotfiles.git
synced 2026-09-11 05:16:22 -07:00
update nvim
This commit is contained in:
@@ -1,18 +1,16 @@
|
||||
-- lua/plugins/codecompanion/fidget-spinner.lua
|
||||
|
||||
local progress = require("fidget.progress")
|
||||
|
||||
local M = {}
|
||||
|
||||
function M:init()
|
||||
local group = vim.api.nvim_create_augroup("CodeCompanionFidgetHooks", {})
|
||||
function M.init()
|
||||
local group = vim.api.nvim_create_augroup("CodeCompanionFidgetHooks", { clear = true })
|
||||
|
||||
vim.api.nvim_create_autocmd({ "User" }, {
|
||||
pattern = "CodeCompanionRequestStarted",
|
||||
group = group,
|
||||
callback = function(request)
|
||||
local handle = M:create_progress_handle(request)
|
||||
M:store_progress_handle(request.data.id, handle)
|
||||
local handle = M.create_progress_handle(request)
|
||||
M.store_progress_handle(request.data.id, handle)
|
||||
end,
|
||||
})
|
||||
|
||||
@@ -20,9 +18,9 @@ function M:init()
|
||||
pattern = "CodeCompanionRequestFinished",
|
||||
group = group,
|
||||
callback = function(request)
|
||||
local handle = M:pop_progress_handle(request.data.id)
|
||||
local handle = M.pop_progress_handle(request.data.id)
|
||||
if handle then
|
||||
M:report_exit_status(handle, request)
|
||||
M.report_exit_status(handle, request)
|
||||
handle:finish()
|
||||
end
|
||||
end,
|
||||
@@ -31,27 +29,28 @@ end
|
||||
|
||||
M.handles = {}
|
||||
|
||||
function M:store_progress_handle(id, handle)
|
||||
function M.store_progress_handle(id, handle)
|
||||
M.handles[id] = handle
|
||||
end
|
||||
|
||||
function M:pop_progress_handle(id)
|
||||
function M.pop_progress_handle(id)
|
||||
local handle = M.handles[id]
|
||||
M.handles[id] = nil
|
||||
return handle
|
||||
end
|
||||
|
||||
function M:create_progress_handle(request)
|
||||
function M.create_progress_handle(request)
|
||||
local adapter = request.data.adapter
|
||||
return progress.handle.create({
|
||||
title = " Requesting assistance (" .. request.data.adapter.model .. ")",
|
||||
title = " Requesting assistance (" .. (adapter.model or "default") .. ")",
|
||||
message = "In progress...",
|
||||
lsp_client = {
|
||||
name = M:llm_role_title(request.data.adapter.name),
|
||||
name = M.llm_role_title(adapter),
|
||||
},
|
||||
})
|
||||
end
|
||||
|
||||
function M:llm_role_title(adapter)
|
||||
function M.llm_role_title(adapter)
|
||||
local parts = {}
|
||||
table.insert(parts, adapter.formatted_name)
|
||||
if adapter.model and adapter.model ~= "" then
|
||||
@@ -60,7 +59,7 @@ function M:llm_role_title(adapter)
|
||||
return table.concat(parts, " ")
|
||||
end
|
||||
|
||||
function M:report_exit_status(handle, request)
|
||||
function M.report_exit_status(handle, request)
|
||||
if request.data.status == "success" then
|
||||
handle.message = "Completed"
|
||||
elseif request.data.status == "error" then
|
||||
|
||||
Reference in New Issue
Block a user