RishabhRD / nvim-lsputils

Better defaults for nvim-lsp actions
456 stars 20 forks source link

CodeAction can't be apply for nvim-jdtls #49

Closed cathaysia closed 2 years ago

cathaysia commented 2 years ago

Please see this gif:

Peek 2021-11-07 14-44

just jdtls, it works for rust.

RishabhRD commented 2 years ago

You are using nvim-jdtls right? Actually, that plugin has changed in past few months. It has moved towards nvim-0.6. nvim-lsputils hasn't changed that much because I wanted to still support nvim-0.5 and was busy in academics so was unable to write compatibility code.

Instead I am maintaining a plugin named lspactions that has much more customization option, and at some point I would deprecate lsputils plugin for that. It is experimental at the moment but mostly works fine and way better than lsputils. I made some bad design choices in lsputils that I wanted to fix but was unable to do because of large user base.

lspactions has many options to do get jdtls working with nice UI.

One of easiest way is having this in your config(in lua):

vim.ui.select = require'lspactions'.select

I am assuming neovim-0.6 here. If you are using neovim 0.5 you can do:

vim.ui = {}
vim.ui.select = require'lspactions'.select

Or, if you don't want changing selector globally:

function require'jdtls.ui'.pick_one_async(items, prompt, label_fn, cb)
    return require'lspactions'.select(items, {
      prompt = prompt,
      format_item = label_fn,
    }, cb)
end
cathaysia commented 2 years ago

Thanks, that(lspactions) must be all I want :)

But on the side, my nvim version is 0.5.1:

NVIM v0.5.1
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Compilation: /usr/bin/gcc -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -Wp,-U_FORTIFY_SOURCE -Wp,-D_FORTIFY_SOURCE=1 -DNVIM_TS_HAS_SET_MATCH_LIMIT -O2 -g -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/builddir/build/BUILD/neovim-0.5.1/redhat-linux-build/config -I/builddir/build/BUILD/neovim-0.5.1/src -I/usr/include -I/usr/include/luajit-2.1 -I/builddir/build/BUILD/neovim-0.5.1/redhat-linux-build/src/nvim/auto -I/builddir/build/BUILD/neovim-0.5.1/redhat-linux-build/include
Compiled by mockbuild@koji

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/share/nvim"

Run :checkhealth for more info

I have switch to lspaction. It fix all problems for me ;)

RishabhRD commented 2 years ago

Okay! closing the issue then.