mfussenegger / nvim-jdtls

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

"Language server `jdtls` does not support command `java.action.applyRefactoringCommand`" #597

Closed mawkler closed 9 months ago

mawkler commented 9 months ago

LSP client configuration

No response

Eclipse.jdt.ls version

v1.30.1

Steps to Reproduce

Hi! Thanks for making this awesome plugin! I just installed it, and when I try and perform the code action "Extract to method" I get the message

Language server `jdtls` does not support command `java.action.applyRefactoringCommand`. This command may require a client extension.

Is this expected behaviour? The README says that extract_method is supported.

This is the config that I'm using:

Click to expand ```lua return { 'nvim-java/nvim-java', dependencies = { 'nvim-java/lua-async-await', 'nvim-java/nvim-java-core', 'nvim-java/nvim-java-test', 'nvim-java/nvim-java-dap', 'MunifTanjim/nui.nvim', 'neovim/nvim-lspconfig', 'mfussenegger/nvim-dap', { 'williamboman/mason.nvim', opts = { registries = { 'github:nvim-java/mason-registry', 'github:mason-org/mason-registry', }, }, }, }, config = function() require('java').setup() require('lspconfig').jdtls.setup({}) end } ```

To reproduce:

  1. Open a .java file
  2. Select text in visual mode
  3. Do :=vim.lsp.buf.code_action()
  4. Select Extract to method
  5. Message pops up

Expected Result

Code action lets me extract code to a new method

Actual Result

I get the message

Language server `jdtls` does not support command `java.action.applyRefactoringCommand`. This command may require a client extension.
mawkler commented 9 months ago

Oups sorry, I got this repo mixed up with nvim-java! 😅

mfussenegger commented 9 months ago

For what's worth, you could probably just add nvim-jdtls in addition to make it work - it registers the client commands if they're missing - so it should mostly complement nvim-java. (But you need to call require("jdtls") for it to happen. Just make sure not to call .start_or_attach if another plugin creates/manages the lsp client)

I don't really understand why its author choose to re-implement pretty much everything. It would be pretty easy to write a wrapper around nvim-jdtls that simplifies the setup. It's also what lsp-zero does (https://github.com/VonHeikemen/lsp-zero.nvim/blob/v3.x/doc/md/guides/setup-with-nvim-jdtls.md), or how some of the distributions work - like lazyvim (https://www.lazyvim.org/extras/lang/java)

mawkler commented 9 months ago

you could probably just add nvim-jdtls in addition to make it work

@mfussenegger Thank you for this, I'll give it a try!