skip to content
Aymen Hafeez

Nvim LSP Progress bar in Ghostty

/ 1 min read

In Neovim, having an autocmd which broadcasts LspProgresss through nvim_echo() will emit and print a progress message from the language server. If using the experimental _core.ui2, interface the progress message will get printed in the message window, similar to what fidget.nvim shows, but done natively.

vim.api.nvim_create_autocmd("LspProgress", {
callback = function(ev)
local value = ev.data.params.value or {}
local msg = value.message or "done"
-- rust-analyzer in particular sends extremely long messages
if #msg > 40 then
msg = msg:sub(1, 37) .. "..."
end
vim.api.nvim_echo({{msg}}, false, {
id = "lsp",
kind = "progress",
title = value.title,
status = value.kind ~= "end" and "running" or "success",
percent = value.percentage,
})
end,
})

Ghostty has a native GUI for showing progress bars reported by the OSC 9;4 escape sequence. What’s cool is that it picks up progress messages emitted by nvim_echo() and integrates it into its progress bar: