Skip to content

Commit b7a4832

Browse files
committed
feat(lspecho): add kind and status to LSP progress echo
Enhance the LSP progress echo by including `kind` and `status` fields in the options passed to `nvim_echo`. This allows for richer status reporting and better integration with features that consume these fields, such as statusline plugins or custom UI components.
1 parent d1e0fb3 commit b7a4832

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

lua/myplugins/lspecho.lua

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ local function log(msg)
3333
local message = msg.message or ''
3434
local percentage = msg.percentage or 0
3535
local history = msg.history or false
36+
local kind = msg.kind or nil
37+
local status = msg.status or nil
3638

3739
local out = ''
3840
if client ~= '' then
@@ -70,7 +72,16 @@ local function log(msg)
7072
local current_time = vim.uv.now()
7173
if current_time - last_echo >= M.config.interval or history then
7274
vim.cmd.redraw()
73-
vim.api.nvim_echo({ { string.sub(out, 1, vim.v.echospace) } }, history, {})
75+
local opts = {}
76+
if kind then
77+
opts.id = 'lsp.' .. client
78+
opts.kind = kind
79+
opts.source = 'vim.lsp'
80+
opts.title = title
81+
opts.status = status
82+
opts.percent = percentage > 0 and percentage or nil
83+
end
84+
vim.api.nvim_echo({ { string.sub(out, 1, vim.v.echospace) } }, history, opts)
7485
last_echo = current_time
7586
end
7687
end
@@ -100,6 +111,8 @@ local function lsp_progress(err, progress, ctx)
100111
title = cur.title,
101112
message = cur.message .. ' - Starting',
102113
percentage = cur.percentage,
114+
kind = 'progress',
115+
status = 'running',
103116
})
104117
elseif value.kind == 'report' then
105118
local cur = series[token]
@@ -108,6 +121,8 @@ local function lsp_progress(err, progress, ctx)
108121
title = value.title or (cur and cur.title),
109122
message = value.message or (cur and cur.message),
110123
percentage = value.percentage or (cur and cur.percentage),
124+
kind = 'progress',
125+
status = 'running',
111126
})
112127
elseif value.kind == 'end' then
113128
local cur = series[token]
@@ -117,6 +132,8 @@ local function lsp_progress(err, progress, ctx)
117132
client = client_name or (cur and cur.client),
118133
title = value.title or (cur and cur.title),
119134
message = msg,
135+
kind = 'progress',
136+
status = 'success',
120137
})
121138
series[token] = nil
122139
clear()

0 commit comments

Comments
 (0)