This commit is contained in:
Hendra 2025-03-15 12:02:58 +07:00
parent 1f78805dc5
commit da73c6c333
3 changed files with 83 additions and 1 deletions

View File

@ -1,7 +1,7 @@
return {
'yetone/avante.nvim',
event = 'VeryLazy',
lazy = false,
lazy = true,
version = false, -- set this if you want to always pull the latest change
opts = {
-- add any opts here

View File

@ -3,9 +3,13 @@ return {
dependencies = {
'nvim-lua/plenary.nvim',
'nvim-treesitter/nvim-treesitter',
'j-hui/fidget.nvim',
-- The following are optional:
{ 'MeanderingProgrammer/render-markdown.nvim', ft = { 'markdown', 'codecompanion' } },
},
init = function()
require('custom.plugins.codecompanion.fidget-spinner'):init()
end,
config = function()
require('codecompanion').setup {
adapters = {
@ -14,6 +18,11 @@ return {
api_key = 'CODECOMP_ANTHROPIC_API_KEY',
},
}),
deepseek = require('codecompanion.adapters').extend('deepseek', {
env = {
api_key = 'CODECOMP_DEEPSEEK_API_KEY',
},
}),
},
strategies = {
chat = {

View File

@ -0,0 +1,73 @@
-- lua/plugins/codecompanion/fidget-spinner.lua
local progress = require 'fidget.progress'
local M = {}
function M:init()
local group = vim.api.nvim_create_augroup('CodeCompanionFidgetHooks', {})
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)
end,
})
vim.api.nvim_create_autocmd({ 'User' }, {
pattern = 'CodeCompanionRequestFinished',
group = group,
callback = function(request)
local handle = M:pop_progress_handle(request.data.id)
if handle then
M:report_exit_status(handle, request)
handle:finish()
end
end,
})
end
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)
return progress.handle.create {
title = ' Requesting assistance (' .. request.data.strategy .. ')',
message = 'In progress...',
lsp_client = {
name = M:llm_role_title(request.data.adapter),
},
}
end
function M:llm_role_title(adapter)
local parts = {}
table.insert(parts, adapter.formatted_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)
if request.data.status == 'success' then
handle.message = 'Completed'
elseif request.data.status == 'error' then
handle.message = ' Error'
else
handle.message = '󰜺 Cancelled'
end
end
return M