Skip to content

Commit f1a87db

Browse files
committed
refactor(ui): show lsp progress in lualine and remove fidget.nvim
1 parent 5bef4ec commit f1a87db

File tree

3 files changed

+35
-32
lines changed

3 files changed

+35
-32
lines changed

lua/modules/configs/ui/fidget.lua

Lines changed: 0 additions & 26 deletions
This file was deleted.

lua/modules/configs/ui/lualine.lua

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,32 @@
1+
local state = { lsp_msg = "" }
2+
local spinners = { "", "󰪞", "󰪟", "󰪠", "󰪡", "󰪢", "󰪣", "󰪤", "󰪥", "" }
3+
vim.api.nvim_create_autocmd("LspProgress", {
4+
pattern = { "begin", "report", "end" },
5+
callback = function(args)
6+
-- Ensure params exists before accessing its fields
7+
if not args.data or not args.data.params then
8+
return
9+
end
10+
11+
local data = args.data.params.value
12+
local progress = ""
13+
14+
if data.percentage then
15+
local idx = math.max(1, math.floor(data.percentage / 10))
16+
local icon = spinners[idx]
17+
progress = icon .. " " .. data.percentage .. "%% "
18+
end
19+
20+
local loaded_count = data.message and string.match(data.message, "^(%d+/%d+)") or ""
21+
local str = progress .. (data.title or "") .. " " .. (loaded_count or "")
22+
state.lsp_msg = data.kind == "end" and "" or str
23+
vim.cmd.redrawstatus()
24+
end,
25+
})
26+
27+
local lsp_msg = function()
28+
return vim.o.columns < 120 and "" or state.lsp_msg
29+
end
130
return function()
231
local has_catppuccin = vim.g.colors_name:find("catppuccin") ~= nil
332
local colors = require("modules.utils").get_palette()
@@ -180,7 +209,12 @@ return function()
180209
end
181210
end
182211
return next(available_servers) == nil and icons.misc.NoActiveLsp
183-
or string.format("%s[%s]", icons.misc.LspAvailable, table.concat(available_servers, ", "))
212+
or string.format(
213+
"%s[%s] %s",
214+
icons.misc.LspAvailable,
215+
table.concat(available_servers, ", "),
216+
lsp_msg()
217+
)
184218
end,
185219
color = utils.gen_hl("blue", true, true, nil, "bold"),
186220
cond = conditionals.has_enough_room,

lua/modules/plugins/ui.lua

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,6 @@ ui["Jint-lzxy/nvim"] = {
1616
name = "catppuccin",
1717
config = require("ui.catppuccin"),
1818
}
19-
ui["j-hui/fidget.nvim"] = {
20-
lazy = true,
21-
event = "LspAttach",
22-
config = require("ui.fidget"),
23-
}
2419
ui["lewis6991/gitsigns.nvim"] = {
2520
lazy = true,
2621
event = { "CursorHold", "CursorHoldI" },

0 commit comments

Comments
 (0)