updates for codecompanion
This commit is contained in:
@@ -11,17 +11,20 @@ return {
|
|||||||
-- "nvim-lualine/lualine.nvim",
|
-- "nvim-lualine/lualine.nvim",
|
||||||
},
|
},
|
||||||
event = "VeryLazy", -- Lazy load the plugin
|
event = "VeryLazy", -- Lazy load the plugin
|
||||||
|
init = function()
|
||||||
|
require("shelbybark.plugins.codecompanion.fidget-spinner"):init()
|
||||||
|
end,
|
||||||
config = function()
|
config = function()
|
||||||
require("codecompanion").setup({
|
require("codecompanion").setup({
|
||||||
ignore_warnings = true,
|
ignore_warnings = true,
|
||||||
strategies = {
|
strategies = {
|
||||||
chat = {
|
chat = {
|
||||||
adapter = "anthropic",
|
adapter = "anthropic_haiku",
|
||||||
},
|
|
||||||
inline = {
|
|
||||||
adapter = "anthropic",
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
|
inline = {
|
||||||
|
adapter = "anthropic_haiku",
|
||||||
|
},
|
||||||
|
},
|
||||||
adapters = {
|
adapters = {
|
||||||
http = {
|
http = {
|
||||||
anthropic = function()
|
anthropic = function()
|
||||||
@@ -82,15 +85,15 @@ return {
|
|||||||
-- Optional: Set up keymaps
|
-- Optional: Set up keymaps
|
||||||
vim.api.nvim_set_keymap(
|
vim.api.nvim_set_keymap(
|
||||||
"n",
|
"n",
|
||||||
"<leader>cc",
|
"<leader>cc",
|
||||||
"<cmd>CodeCompanionChat anthropic_haiku Toggle<cr>",
|
"<cmd>CodeCompanionChat anthropic_haiku Toggle<cr>",
|
||||||
{ noremap = true, silent = true, desc = "Chat with Claude Haiku" }
|
{ noremap = true, silent = true, desc = "Chat with Claude Haiku" }
|
||||||
)
|
)
|
||||||
vim.api.nvim_set_keymap(
|
vim.api.nvim_set_keymap(
|
||||||
"v",
|
"v",
|
||||||
"<leader>cc",
|
"<leader>cc",
|
||||||
"<cmd>CodeCompanionChat anthropic_haiku Toggle<cr>",
|
"<cmd>CodeCompanionChat anthropic_haiku Toggle<cr>",
|
||||||
{ noremap = true, silent = true, desc = "Chat with Claude Haiku" }
|
{ noremap = true, silent = true, desc = "Chat with Claude Haiku" }
|
||||||
)
|
)
|
||||||
vim.api.nvim_set_keymap("n", "<leader>ca", "<cmd>CodeCompanionActions<cr>", { noremap = true, silent = true })
|
vim.api.nvim_set_keymap("n", "<leader>ca", "<cmd>CodeCompanionActions<cr>", { noremap = true, silent = true })
|
||||||
vim.api.nvim_set_keymap("v", "<leader>ca", "<cmd>CodeCompanionActions<cr>", { noremap = true, silent = true })
|
vim.api.nvim_set_keymap("v", "<leader>ca", "<cmd>CodeCompanionActions<cr>", { noremap = true, silent = true })
|
||||||
|
|||||||
71
lua/shelbybark/plugins/codecompanion/fidget-spinner.lua
Normal file
71
lua/shelbybark/plugins/codecompanion/fidget-spinner.lua
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
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",
|
||||||
|
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
|
||||||
Reference in New Issue
Block a user