fidget.nvim
fidget.nvim copied to clipboard
nvim-jdtls support
Hi, I managed to make nvim-jdtls work with fidget with the following progress reporting function:
local function progress_report(_, result, ctx)
local lsp = vim.lsp
local info = {
client_id = ctx.client_id,
}
local kind = "report"
if result.complete then
kind = "end"
elseif result.workDone == 0 then
kind = "begin"
elseif result.workDone > 0 and result.workDone < result.totalWork then
kind = "report"
else
kind = "end"
end
local percentage = 0
if result.totalWork > 0 and result.workDone >= 0 then
percentage = result.workDone / result.totalWork * 100
end
local msg = {
token = result.id,
value = {
kind = kind,
percentage = percentage,
title = result.subTask,
message = result.subTask,
},
}
-- print(vim.inspect(result))
lsp.handlers["$/progress"](nil, msg, info)
end
And then start jdtls with the following:
require("jdtls").start_or_attach({
handlers = {
["language/progressReport"] = progress_report,
},
})
It actually works pretty well. I haven't look into the code of fidget yet, but probably we could integrate this into fidget to make it works out of box.
Thanks
Personally I find that it makes more sense to use result.task instead of result.subTask for msg.value.title. Regardless, I do see Completed [nil] fidgets for some reason..
I ran into this issue as well (nice plugin btw 👌) and I'm wondering if nvim-jdtls should handle this by mapping jdtls' specific "language/progressReport" event to "$/progress".
@mfussenegger, what do you think? This could be relevant for other plugins as well (e.g. lualine-lsp-progress).
Thanks for figuring that out @litao91 ! Another alternative is that I just use get_progress_messages() as Fidget's backend (rather than directly overwriting the progress handler), as suggested in #51.
I implemented $/progress in jdtls (see https://github.com/eclipse/eclipse.jdt.ls/pull/2030).

Depending on the jdtls maintainers' responses I think this issue could be closed.
wow @schrieveslaach that's awesome! I'll consider this particular issue closed once that PR lands
Cheers to @schrieveslaach, https://github.com/eclipse/eclipse.jdt.ls/pull/2030 is now merged, set progressReportProvider = false to use $/progress
init_options = {
extendedClientCapabilities = {
progressReportProvider = false,
},
},
LSP[jdtls] received end message with no corresponding begin
@yil3 use the latest version of jdt.ls snapshot build
Closed by #143