Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

code actions with nvim-jdtls not working #314

Closed
abenz1267 opened this issue Jan 17, 2022 · 12 comments
Closed

code actions with nvim-jdtls not working #314

abenz1267 opened this issue Jan 17, 2022 · 12 comments
Labels
feature request New feature

Comments

@abenz1267
Copy link
Contributor

abenz1267 commented Jan 17, 2022

Hi (again... i must be annoying),

some code actions don't work using nvim-jdtls, same problem as with f.e. telescope:

No delegateCommandHandler for java.action.organizeImports

Maybe see this for reference: mfussenegger/nvim-jdtls#192

Regards

Edit: i also just realized code actions with gopls don't work. f.e. organize imports or add import. no error though. just doesn't work.

@ibhagwan ibhagwan added the bug Something isn't working label Jan 17, 2022
@ibhagwan
Copy link
Owner

Hi (again... i must be annoying),

Dw about it, every issue makes this plugin better :-)

Not sure how to handle this issue though, in the linked jdtls issue there's no alternative suggested other than using the builtin menu vim.lsp.buf.code_action(), I'll do some more digging, any addittional info you can provide will be helpful as I never programmed in Java or tested jdtls.

Edit: i also just realized code actions with gopls don't work. f.e. organize imports or add import. no error though. just doesn't work.

I just installed gopls and tried it, it worked with 0.6.1 but failed with the nightly, similar to #306 with 0.7 the API requires an addtional offset_encoding paramter to be sent to vim.lsp.util.apply_workspace_edit.

If you're using the nightly update to the latest commit and code actions should work again, below is my test with gopls:

Peek 2022-01-17 09-07

@abenz1267
Copy link
Contributor Author

yes, seems to be fixed for Go.

As for the Java problem: as I understood it's a matter of fzf-lua missing some code_action implementations (...or having them 'wrong'). I will see if i can find out what's missing.

@abenz1267
Copy link
Contributor Author

abenz1267 commented Jan 18, 2022

Apparently being able to use vim.ui.select with fzf-lua would solve the issue.

see https://github.com/nvim-telescope/telescope-ui-select.nvim

Meaning: using fzf-lua for the vim.ui.selection instead of the native one.

regards

@ibhagwan
Copy link
Owner

Apparently being able to use vim.ui.select with fzf-lua would solve the issue.

see https://github.com/nvim-telescope/telescope-ui-select.nvim

Meaning: using fzf-lua for the vim.ui.selection instead of the native one.

regards

I know about vim.ui.select but it’s not a solution for this issue but rather a workaround, if implemented the UI for lsp.but.code_action will be replaced with fzf-lua to be used instead of the neovim default menu, then upon selection neovim executes the selection.

I haven’t looked into it yet, I’m not sure if it can be implemented for code actions only or, when defined, it takes over other LSP selectors too.

If that’s the only solution than it’s more of a “feature request” as it’s a new approach with a new implementation, I’ll leave this issue open until I can get to the bottom of this.

@ibhagwan ibhagwan added feature request New feature and removed bug Something isn't working labels Jan 18, 2022
@abenz1267
Copy link
Contributor Author

Hm, i'd agree this seems like a new feature rather than a bug. Personally i'd def. like it. Having a consistent experience is rather valuable. Right now i only use the in-build vim.ui.select for JDTLS .... having it in fzf-lua (and therefore also filterable) would be nice.

@ibhagwan
Copy link
Owner

Let me look into it, might be rather simple.

@ibhagwan
Copy link
Owner

Added in the latest commit, all you have to do now is call:

:lua require'fzf-lua'.register_ui_select()

@abenz1267
Copy link
Contributor Author

i actually got out of bed again to test this. works like a charm! really good job with this plugin man. i used telescope before, but it's unusable with the main project at work, because it's too slow. no issues with this one. thanks a ton!

@ibhagwan
Copy link
Owner

ibhagwan commented Jan 18, 2022

You're welcome! just added the ability to send custom options to it (any other option that works with fzf-lua should work here), for example:

:lua require'fzf-lua'.register_ui_select({ prompt='Test> ', winopts = { win_height=0.30, win_width=0.60 } })

Edit: also forgot to mention you can always revert back with:

:lua require'fzf-lua'.deregister_ui_select()

@abenz1267
Copy link
Contributor Author

i noticed that if you are in visual mode, f.e. for vim.lsp.buf.range_code_action(), then you don't enter insert mode automatically.

@ibhagwan
Copy link
Owner

5b52706 fixed

@ibhagwan
Copy link
Owner

FYI, latest commit 8e37ef6 also makes sure it works properly with resume, it's pretty cool as you can open the last code action anywhere else in the document and still apply it, watch the below:

  • Code action: ignore diag for single line
  • Undo + go to start of file
  • Open code action again with resume
  • Apply ignore single file

Peek 2022-01-18 13-41

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature
Projects
None yet
Development

No branches or pull requests

2 participants