This commit is contained in:
sudacode 2025-02-26 14:55:20 -08:00
parent e5a4785c0c
commit b4789ac055
Signed by: sudacode
SSH Key Fingerprint: SHA256:lT5C2bB398DcX6daCF/gYFNSTK3y+Du3oTGUnYzfTEw
7 changed files with 166 additions and 136 deletions

View File

@ -2,14 +2,15 @@
"LuaSnip": { "branch": "master", "commit": "03c8e67eb7293c404845b3982db895d59c0d1538" },
"any-jump.vim": { "branch": "master", "commit": "f95674d9a4251ac02f452d5f1861e4422f4652c7" },
"bufferline.nvim": { "branch": "main", "commit": "655133c3b4c3e5e05ec549b9f8cc2894ac6f51b3" },
"catppuccin": { "branch": "main", "commit": "4bb938bbba41d306db18bf0eb0633a5f28fd7ba0" },
"catppuccin": { "branch": "main", "commit": "7ab1a6ec70a664ecb95d84669efc20aaf4f4ed1b" },
"cmp-async-path": { "branch": "main", "commit": "d6d1ffa2075039632a2d71e8fa139818e15ac757" },
"cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" },
"cmp-cmdline": { "branch": "main", "commit": "d250c63aa13ead745e3a40f61fdd3470efde3923" },
"cmp-nvim-lsp-document-symbol": { "branch": "main", "commit": "f94f7ba948e32cd302caba1c2ca3f7c697fb4fcf" },
"cmp-nvim-lsp-signature-help": { "branch": "main", "commit": "031e6ba70b0ad5eee49fd2120ff7a2e325b17fa7" },
"cmp_luasnip": { "branch": "master", "commit": "98d9cb5c2c38532bd9bdb481067b20fea8f32e90" },
"codecompanion.nvim": { "branch": "main", "commit": "5dd1151df3ee66fb5f4a2471dab23269c56ceba3" },
"codecompanion.nvim": { "branch": "main", "commit": "c3add8138fe624b794d2226fb04c8540cea73aa7" },
"conform.nvim": { "branch": "master", "commit": "a6f5bdb78caa305496357d17e962bbc4c0b392e2" },
"copilot-cmp": { "branch": "master", "commit": "15fc12af3d0109fa76b60b5cffa1373697e261d1" },
"copilot-lualine": { "branch": "main", "commit": "dc4b8ed0f75bc2557b3158c526624bf04ad233ea" },
"copilot.lua": { "branch": "master", "commit": "30321e33b03cb924fdcd6a806a0dc6fa0b0eafb9" },
@ -21,13 +22,13 @@
"goto-preview": { "branch": "main", "commit": "4751e70a6ebce4fb78327b097cb8fdff55f38f3a" },
"image.nvim": { "branch": "master", "commit": "6ffafab2e98b5bda46bf227055aa84b90add8cdc" },
"indent-blankline.nvim": { "branch": "master", "commit": "e10626f7fcd51ccd56d7ffc00883ba7e0aa28f78" },
"lazy.nvim": { "branch": "main", "commit": "a8c6db5da7bd382094606340eed015d14fbb5654" },
"lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" },
"lazydev.nvim": { "branch": "main", "commit": "2367a6c0a01eb9edb0464731cc0fb61ed9ab9d2c" },
"lsp_lines.nvim": { "branch": "main", "commit": "a92c755f182b89ea91bd8a6a2227208026f27b4d" },
"lspkind.nvim": { "branch": "master", "commit": "d79a1c3299ad0ef94e255d045bed9fa26025dab6" },
"lualine.nvim": { "branch": "master", "commit": "f4f791f67e70d378a754d02da068231d2352e5bc" },
"mini.diff": { "branch": "main", "commit": "bc3a7be30fd45ed4961ea90de1d9d04637cdeae6" },
"mini.nvim": { "branch": "main", "commit": "dece5fdca1517425bee1af042f4b3c1323405f5d" },
"mini.nvim": { "branch": "main", "commit": "e554890210cd29d017d6a0c1b1a46f995dcf9e64" },
"noice.nvim": { "branch": "main", "commit": "0427460c2d7f673ad60eb02b35f5e9926cf67c59" },
"none-ls.nvim": { "branch": "main", "commit": "a66b5b9ad8d6a3f3dd8c0677a80eb27412fa5056" },
"nui.nvim": { "branch": "main", "commit": "53e907ffe5eedebdca1cd503b00aa8692068ca46" },
@ -36,18 +37,18 @@
"nvim-colorizer.lua": { "branch": "master", "commit": "a065833f35a3a7cc3ef137ac88b5381da2ba302e" },
"nvim-html-css": { "branch": "main", "commit": "fa7e2da75edfd3d110fc8d4f8e5215b5de56ff42" },
"nvim-lint": { "branch": "master", "commit": "6e9dd545a1af204c4022a8fcd99727ea41ffdcc8" },
"nvim-lspconfig": { "branch": "master", "commit": "9e932edb0af4e20880685ddb96a231669fbe8091" },
"nvim-lspconfig": { "branch": "master", "commit": "5344e00b86d1ea50c39a1da8af9f3d197234bcfe" },
"nvim-nio": { "branch": "master", "commit": "21f5324bfac14e22ba26553caf69ec76ae8a7662" },
"nvim-notify": { "branch": "master", "commit": "22f29093eae7785773ee9d543f8750348b1a195c" },
"nvim-tree.lua": { "branch": "master", "commit": "6709463b2d18e77f7a946027917aa00d4aaed6f4" },
"nvim-treesitter": { "branch": "master", "commit": "9fcb3f7aa2504307eaaebcc600ed2063d681f80e" },
"nvim-treesitter": { "branch": "master", "commit": "8f87d28442f7f91347e993661c319135f47729c7" },
"nvim-web-devicons": { "branch": "master", "commit": "1020869742ecb191f260818234517f4a1515cfe8" },
"obsidian.nvim": { "branch": "main", "commit": "ae1f76a75c7ce36866e1d9342a8f6f5b9c2caf9b" },
"odis": { "branch": "master", "commit": "5176a07a729860d0c0cdefe96252fc7ff9e16d43" },
"plenary.nvim": { "branch": "master", "commit": "857c5ac632080dba10aae49dba902ce3abf91b35" },
"presence.nvim": { "branch": "main", "commit": "87c857a56b7703f976d3a5ef15967d80508df6e6" },
"rainbow-delimiters.nvim": { "branch": "master", "commit": "011d98eaa3a73b5a51d82ce5bc6b1397dde95562" },
"render-markdown.nvim": { "branch": "main", "commit": "21623a9ded5a5f3d1fbd8626a69c174fbeb0543e" },
"render-markdown.nvim": { "branch": "main", "commit": "1cd546e96cb8520a148610ca86596ed238eeb936" },
"telescope-color-names.nvim": { "branch": "main", "commit": "95b372b9a8ba0fc7cf6a67be637ee37453f322da" },
"telescope-file-browser.nvim": { "branch": "master", "commit": "626998e5c1b71c130d8bc6cf7abb6709b98287bb" },
"telescope-fzf-native.nvim": { "branch": "main", "commit": "2a5ceff981501cff8f46871d5402cd3378a8ab6a" },

View File

@ -61,9 +61,9 @@ vim.cmd([[
-- }}}
-- {{{ Code companion hook
local group = vim.api.nvim_create_augroup("CodeCompanionHooks", {})
local group = augroup("CodeCompanionHooks", {})
vim.api.nvim_create_autocmd({ "User" }, {
autocmd({ "User" }, {
pattern = "CodeCompanionInline*",
group = group,
callback = function(request)

View File

@ -214,8 +214,8 @@ local code_companion_mappings = {
{
mode = "v",
key = "<leader>Ci",
cmd = ":CodeCompanion /buffer ",
group = "CodeCompanion /buffer",
cmd = ":CodeCompanion #buffer ",
group = "CodeCompanion #buffer",
opts = nosilent,
},
{ mode = "v", key = "<leader>Ce", cmd = ":CodeCompanion /explain<CR>", group = "CodeCompanion /explain" },

View File

@ -0,0 +1,126 @@
local notify = require("notify")
local spinner_frames = { "", "", "", "", "", "", "", "", "", "" }
local spinner_len = #spinner_frames -- cache spinner length
local M = {}
local timeout = 2999
-- Helper function to safely call notify
local function safe_notify(msg, level, opts)
local ok, res = pcall(notify, msg, level, opts)
return ok, res
end
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)
local title = " Requesting assistance"
.. " ("
.. request.data.strategy
.. ") from "
.. request.data.adapter.formatted_name
.. " using "
.. request.data.adapter.model
local idx = 1
local start_time = os.time()
local notification_id =
notify(spinner_frames[idx] .. " In progress (" .. "0s" .. ")...", "info", { title = title, timeout = false })
local handle = { notification_id = notification_id, title = title, finished = false }
local timer = vim.loop.new_timer()
timer:start(
0,
100,
vim.schedule_wrap(function()
if handle.finished then
return
end -- stop updating if finished
idx = idx % spinner_len + 1
local elapsed = os.difftime(os.time(), start_time)
local opts = { replace = handle.notification_id, title = title, timeout = false }
local ok, new_id = safe_notify(spinner_frames[idx] .. " In progress (" .. elapsed .. "s)...", "info", opts)
if ok then
handle.notification_id = new_id
else
handle.notification_id = notify(
spinner_frames[idx] .. " In progress (" .. elapsed .. "s)...",
"info",
{ title = title, timeout = false }
)
end
end)
)
handle.timer = timer
handle.finish = function()
handle.finished = true -- mark as finished to abort future updates
if handle.timer then
handle.timer:stop()
handle.timer:close()
handle.timer = nil
end
end
return handle
end
function M:report_exit_status(handle, request)
local title = handle.title
or (
" Requesting assistance"
.. " ("
.. request.data.strategy
.. ") from "
.. request.data.adapter.formatted_name
.. " using "
.. request.data.adapter.model
)
local function report(msg, level)
local opts = { replace = handle.notification_id, title = title, timeout = timeout }
local ok = safe_notify(msg, level, opts)
if not ok then
notify(msg, level, { title = title, timeout = timeout })
end
end
if request.data.status == "success" then
report("Completed", "info")
elseif request.data.status == "error" then
report(" Error", "error")
else
report("󰜺 Cancelled", "warn")
end
end
return M

View File

@ -1,14 +1,8 @@
local notify = require("notify")
local spinner_frames = { "", "", "", "", "", "", "", "", "", "" }
local spinner_len = #spinner_frames -- cache spinner length
local M = {}
local timeout = 2999
-- lua/plugins/codecompanion/fidget-spinner.lua
-- Helper function to safely call notify
local function safe_notify(msg, level, opts)
local ok, res = pcall(notify, msg, level, opts)
return ok, res
end
local progress = require("fidget.progress")
local M = {}
function M:init()
local group = vim.api.nvim_create_augroup("CodeCompanionFidgetHooks", {})
@ -48,78 +42,31 @@ function M:pop_progress_handle(id)
end
function M:create_progress_handle(request)
local title = " Requesting assistance"
.. " ("
.. request.data.strategy
.. ") from "
.. request.data.adapter.formatted_name
.. " using "
.. request.data.adapter.model
local idx = 1
local start_time = os.time()
local notification_id =
notify(spinner_frames[idx] .. " In progress (" .. "0s" .. ")...", "info", { title = title, timeout = false })
local handle = { notification_id = notification_id, title = title, finished = false }
local timer = vim.loop.new_timer()
timer:start(
0,
100,
vim.schedule_wrap(function()
if handle.finished then
return
end -- stop updating if finished
idx = idx % spinner_len + 1
local elapsed = os.difftime(os.time(), start_time)
local opts = { replace = handle.notification_id, title = title, timeout = false }
local ok, new_id = safe_notify(spinner_frames[idx] .. " In progress (" .. elapsed .. "s)...", "info", opts)
if ok then
handle.notification_id = new_id
else
handle.notification_id = notify(
spinner_frames[idx] .. " In progress (" .. elapsed .. "s)...",
"info",
{ title = title, timeout = false }
)
end
end)
)
handle.timer = timer
handle.finish = function()
handle.finished = true -- mark as finished to abort future updates
if handle.timer then
handle.timer:stop()
handle.timer:close()
handle.timer = nil
end
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 handle
return table.concat(parts, " ")
end
function M:report_exit_status(handle, request)
local title = handle.title
or (
" Requesting assistance"
.. " ("
.. request.data.strategy
.. ") from "
.. request.data.adapter.formatted_name
.. " using "
.. request.data.adapter.model
)
local function report(msg, level)
local opts = { replace = handle.notification_id, title = title, timeout = timeout }
local ok = safe_notify(msg, level, opts)
if not ok then
notify(msg, level, { title = title, timeout = timeout })
end
end
if request.data.status == "success" then
report("Completed", "info")
handle.message = "Completed"
elseif request.data.status == "error" then
report(" Error", "error")
handle.message = " Error"
else
report("󰜺 Cancelled", "warn")
handle.message = "󰜺 Cancelled"
end
end

4
lua/plugins/conform.lua Normal file
View File

@ -0,0 +1,4 @@
return {
"stevearc/conform.nvim",
opts = {},
}

View File

@ -1,54 +1,6 @@
return {
"nvim-lualine/lualine.nvim",
config = function()
local M = require("lualine.component"):extend()
M.processing = false
M.spinner_index = 1
local spinner_symbols = {
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
}
local spinner_symbols_len = 10
-- Initializer
function M:init(options)
M.super.init(self, options)
local group = vim.api.nvim_create_augroup("CodeCompanionHooks", {})
vim.api.nvim_create_autocmd({ "User" }, {
pattern = "CodeCompanionRequest*",
group = group,
callback = function(request)
if request.match == "CodeCompanionRequestStarted" then
self.processing = true
elseif request.match == "CodeCompanionRequestFinished" then
self.processing = false
end
end,
})
end
-- Function that runs every time statusline is updated
function M:update_status()
if self.processing then
self.spinner_index = (self.spinner_index % spinner_symbols_len) + 1
return spinner_symbols[self.spinner_index]
else
return nil
end
end
require("lualine").setup({
options = {
icons_enabled = true,
@ -66,8 +18,8 @@ return {
lualine_b = { "branch", "diff" },
lualine_c = { "filename" },
lualine_x = {
M,
{
"seachcount",
"copilot",
symbols = {
status = {
@ -130,7 +82,7 @@ return {
lualine_z = {},
},
tabline = {},
extensions = { "quickfix", "fzf", "nvim-tree", "symbols-outline", "fugitive" },
extensions = { "quickfix", "fzf", "nvim-tree", "symbols-outline", "fugitive", "toggleterm", "man" },
})
end,
depends = { "kyazdani42/nvim-web-devicons" },