mfussenegger / nvim-jdtls

Extensions for the built-in LSP support in Neovim for eclipse.jdt.ls
GNU General Public License v3.0
1.09k stars 62 forks source link

Use an UI to override/implement methods. #358

Open DasOhmoff opened 1 year ago

DasOhmoff commented 1 year ago

Problem Statement

Hey 👋, thank you for your nice work!

Right now, when I try to implement methods, using the command line to select them is pretty uncomfortable, and also not very nice looking: image

It would be nice to have some UI to be able to do that instead.

Ideas or possible solutions

One could use f.e telescope to be able to select that. Telescope offers the ability to select the items: image I am just demonstrating the Idea, of course selecting multiple code actions and applying them does not work with LSPs.

Thank you very much for your support :)

mfussenegger commented 1 year ago

Improving the UI sounds good, but I don't want nvim-jdtls to have a dependency on telescope and would rather have an abstraction that allows users to plug-in different implementations.

A first step would be to change jdtls.ui.pick_many to be async. Then it could be overridden with a telescope specific implementation. (See also this PR in neovim that would go into this direction: https://github.com/neovim/neovim/pull/18161)

DasOhmoff commented 1 year ago

Nice. I like this. I did not mean to add a telescope dependency anyway, I was just showing that the concept of the UI would improve things.

So is there a plan or so in regards to this issue?

mfussenegger commented 1 year ago

With https://github.com/mfussenegger/nvim-jdtls/pull/360 all jdtls.ui.pick_many calls are now happening inside a coroutine, so it would be possible to do something like:

require('jdtls.ui').pick_many = function(items, prompt, label_f, opts)
  local co = coroutine.running()
  call_other_async_version(..., function(result)
    coroutine.resume(co, result)
  end)
  return coroutine.yield()
end)

Changing the default implementation is still on my todo

DasOhmoff commented 1 year ago

Ah, perfekt. Thanks! Waiting for the default too 👀