Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings
nvim-java

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Issue going to definition of library classes and methods#435

Kobu started this conversation inGeneral
Discussion options

Hello, i am quite sure something is wrong with my config, hence I wont open a new issue, but I cannot seem to solve this by myself

Overall, nvim-java works just fine with me, however I cannot go to definitions of library/external classes and methods, which is a deal breaker.
I wondered if the issue is with my project, however after opening the project in intellij everything worked just fine.
This is the config I'm using, unlike most of the discussions used here, I don't use Lazy, just an old packer config.

init.lua

localjava_setup=require("java")java_setup.setup({java_test= {enable=false,  },-- load java debugger pluginsjava_debug_adapter= {enable=false,  },spring_boot_tools= {enable=false,  },-- Use Java 21 for jdtls (required for Gradle 9.1.0 and Fabric Loom)jdtls= {settings= {java= {eclipse= {downloadSources=true },maven= {downloadSources=true },configuration= {runtimes= {            {name="JavaSE-21",path="/usr/lib/jvm/java-21-openjdk",default=true,            },          },        },      },    },  },})

lua/user/lsp.lua

require("mason").setup()locallsp_installer=load_plugin("mason-lspconfig")ifnotlsp_installerthenreturnendlocallsp_signature=load_plugin("lsp_signature")ifnotlsp_signaturethenreturnendlocallspconfig=require("lspconfig")localhandlers= {  ["textDocument/hover"]=vim.lsp.with(vim.lsp.handlers.hover, {border="rounded"}),  ["textDocument/signatureHelp"]=vim.lsp.with(vim.lsp.handlers.signature_help, {border="rounded"}),}localcapabilities=require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities())localworkspace= {didChangeWatchedFiles= {dynamicRegistration=false,  },}capabilities.workspace=workspace-- buffer = 0 : current bufferlocalon_attach=function(_,bufnr)vim.keymap.set("n","K",vim.lsp.buf.hover, {buffer=0 })vim.keymap.set("n","R",vim.lsp.buf.rename, {buffer=0 })vim.keymap.set("n","sk",vim.diagnostic.goto_prev)vim.keymap.set("n","sj",vim.diagnostic.goto_next)vim.keymap.set("n","sdb",vim.lsp.buf.definition)vim.keymap.set("n","sa",vim.lsp.buf.code_action, {buffer=0 })lsp_signature.on_attach({toggle_key="<C-h>",doc_lines=0,hint_enable=false,bind=true,handler_opts= {border="rounded",    },  },bufnr)endlspconfig.jdtls.setup({on_attach=on_attach,capabilities=capabilities,handlers=handlers,})

I was hoping the comment here#398 (comment) would fix my issues, however it did not work.

I am using nvim v11 and java 21 on arch linux machine

You must be logged in to vote

Replies: 2 comments 7 replies

Comment options

-- Use Java 21 for jdtls (required for Gradle 9.1.0 and Fabric Loom)

I've found out that adding jdtls configuration somehow messes the LSP functionality. I don't know how, I don't know why.

Also I don't think this is necessary. If Java 21 is your default JDK that runs when you issuejava command, then it should by default run with it.

Also this doesn't change what JDK jdtls runs with. It only changes the source compatibility level. What really determines what java jdtls runs with is the java version that's in your PATH.

Unfortunately I don't have any time to put into nvim-java right now. Otherwise I'd go deeper in the code and try to fix all the issues users are complaining for.

You must be logged in to vote
0 replies
Comment options

By adding jdtls configuration, do you mean any configuration whatsoever? Or just jdk-specific configuration? If so would u suggest not using thejdtls config field at all?

Also I tried setting the JDK version this way, as a last ditch effort, its just one of the many permutations of configurations I tried, but to no avail.

Btw completely understandable that you don't have time right now.

You must be logged in to vote
7 replies
@logrusx
Comment options

I have noticed i cannot even go to definitions of classes from standard library,String for example. Does this in any way narrow down where the problem might be?

Unfortunately it doesn't. I've spent a little time on this and haven't found any clues.

@Kobu
Comment options

After all it does seem like this is a project specific issue. This is the repo in question:https://github.com/FabricMC/fabric-example-mod
Would you mind trying for yourself? At this point I am quite unsure which piece of magic is breaking go-to definition, even for classes likeString, but IntelliJ seems to handle it just fine. I will investigate further.

Edit: I tried with barebone LazyVim distribution and the same issue is present, so most likely not a problem with my config

@logrusx
Comment options

I'm sorry to disappoint you that my Neovim configuration is not currently in a state to test things and get conclusive results due to attempts to migrate nvim-java to using the new vim.lsp API and ditch neovim-lspconfig.

However I remember I had other discussions on the subject, I in some issues, some of them might be already closed, where I had posted configuration that downloaded sources for the dependencies and showed the definitions.

Maybe if you show me your complete Neovim configuration I can help. At this point I've developer a laser vision for potential issues concerning nvim-java.

@Kobu
Comment options

Understandable.

Amd yes, i have went thourgh every issue or discussion in this repo (and other lol) that might point me to a solution. I think the fix you are mentioning is this one#398 (comment) howerever that did not work for me.

As I said, I just tested with brand new LazyVim and its the same issue. This leads me to the conclusion that the project is setup up in a way thatneovim, or rather nvim-java/jdtls does not support, but intellij and vscode do

@logrusx
Comment options

I think the fix you are mentioning is this one#398 (comment) howerever that did not work for me.

Yes, that must be it.

As I said, I just tested with brand new LazyVim and its the same issue. This leads me to the conclusion that the project is setup up in a way thatneovim, or rather nvim-java/jdtls does not support, but intellij and vscode do

I looked at the project you linked above but unfortunately it's gradle. I'm not too familiar with it.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Category
General
Labels
None yet
2 participants
@Kobu@logrusx

[8]ページ先頭

©2009-2025 Movatter.jp