fidget.nvim icon indicating copy to clipboard operation
fidget.nvim copied to clipboard

nvim-jdtls support

Open litao91 opened this issue 3 years ago • 8 comments

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

litao91 avatar Mar 11 '22 08:03 litao91

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..

axieax avatar Mar 14 '22 13:03 axieax

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).

schrieveslaach avatar Mar 18 '22 15:03 schrieveslaach

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.

j-hui avatar Mar 20 '22 02:03 j-hui

I implemented $/progress in jdtls (see https://github.com/eclipse/eclipse.jdt.ls/pull/2030).

output

Depending on the jdtls maintainers' responses I think this issue could be closed.

schrieveslaach avatar Mar 20 '22 15:03 schrieveslaach

wow @schrieveslaach that's awesome! I'll consider this particular issue closed once that PR lands

j-hui avatar Mar 23 '22 21:03 j-hui

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,
    },
},

20220830_215026_wf.webm

fitrh avatar Aug 30 '22 14:08 fitrh

LSP[jdtls] received end message with no corresponding begin

xYx-c avatar Sep 01 '22 02:09 xYx-c

@yil3 use the latest version of jdt.ls snapshot build

fitrh avatar Sep 01 '22 02:09 fitrh

Closed by #143

j-hui avatar Nov 10 '23 01:11 j-hui