Skip to content

Commit 84740fb

Browse files
committed
Update statusline to have better output for static status messages
1 parent 8ffbae3 commit 84740fb

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

lua/lsp-status/statusline.lua

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,9 @@ local function statusline_lsp()
4848
for _, msg in ipairs(buf_messages) do
4949
local name = aliases[msg.name] or msg.name
5050
local client_name = '[' .. name .. ']'
51+
local contents = ''
5152
if msg.progress then
52-
local contents = msg.title
53+
contents = msg.title
5354
if msg.message then
5455
contents = contents .. ' ' .. msg.message
5556
end
@@ -61,11 +62,23 @@ local function statusline_lsp()
6162
if msg.spinner then
6263
contents = vim.g.spinner_frames[(msg.spinner % #vim.g.spinner_frames) + 1] .. ' ' .. contents
6364
end
65+
elseif msg.status then
66+
contents = msg.content
67+
if msg.uri then
68+
local filename = vim.uri_to_fname(msg.uri)
69+
filename = vim.fn.fnamemodify(filename, ':~:.')
70+
local space = math.min(60, math.floor(0.6 * vim.fn.winwidth(0)))
71+
if #filename > space then
72+
filename = vim.fn.pathshorten(filename)
73+
end
6474

65-
table.insert(msgs, client_name .. ' ' .. contents)
75+
contents = '(' .. filename .. ') ' .. contents
76+
end
6677
else
67-
table.insert(msgs, client_name .. ' ' .. msg.content)
78+
contents = msg.content
6879
end
80+
81+
table.insert(msgs, client_name .. ' ' .. contents)
6982
end
7083

7184
local base_status = vim.trim(table.concat(status_parts, ' ') .. ' ' .. table.concat(msgs, ' '))

0 commit comments

Comments
 (0)