无法使用 LspInstall 让 jdtls 在 neovim 中工作

问题描述 投票:0回答:1

我目前正在尝试让 jdtls 在我的 neovim 配置中工作,但每次我打开 java 文件时它都无法正常启动

lsp.log 的内容如下:

[START][2023-04-20 14:25:54] LSP logging initiated
[ERROR][2023-04-20 14:25:54] .../vim/lsp/rpc.lua:734    "rpc"   "jdtls" "stderr"    "WARNING: Using incubator modules: jdk.incubator.concurrent, jdk.incubator.vector\n"
[WARN][2023-04-20 14:26:13] ...lsp/handlers.lua:137 "The language server jdtls triggers a registerCapability handler despite dynamicRegistration set to false. Report upstream, this warning is harmless"
[WARN][2023-04-20 14:26:13] .../lua/vim/lsp.lua:1073    "server_request: no handler found for"  "workspace/executeClientCommand"
[ERROR][2023-04-20 14:26:16] ...lsp/handlers.lua:535    "Apr 20, 2023, 2:26:16 PM org.eclipse.lsp4j.jsonrpc.ResponseErrorException: MethodNotFound\norg.eclipse.lsp4j.jsonrpc.ResponseErrorException: MethodNotFound\njava.util.concurrent.CompletionException: org.eclipse.lsp4j.jsonrpc.ResponseErrorException: MethodNotFound\n\tat java.base/java.util.concurrent.CompletableFuture.reportJoin(CompletableFuture.java:413)\n\tat java.base/java.util.concurrent.CompletableFuture.join(CompletableFuture.java:2118)\n\tat org.eclipse.jdt.ls.core.internal.JavaClientConnection.executeClientCommand(JavaClientConnection.java:93)\n\tat org.eclipse.jdt.ls.core.internal.handlers.JDTLanguageServer.synchronizeBundles(JDTLanguageServer.java:414)\n\tat org.eclipse.jdt.ls.core.internal.handlers.JDTLanguageServer$2.run(JDTLanguageServer.java:301)\n\tat org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)\nCaused by: org.eclipse.lsp4j.jsonrpc.ResponseErrorException: MethodNotFound\n\tat org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.handleResponse(RemoteEndpoint.java:209)\n\tat org.eclipse.lsp4j.jsonrpc.RemoteEndpoint.consume(RemoteEndpoint.java:193)\n\tat org.eclipse.jdt.ls.core.internal.ParentProcessWatcher.lambda$1(ParentProcessWatcher.java:144)\n\tat org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.handleMessage(StreamMessageProducer.java:194)\n\tat org.eclipse.lsp4j.jsonrpc.json.StreamMessageProducer.listen(StreamMessageProducer.java:94)\n\tat org.eclipse.lsp4j.jsonrpc.json.ConcurrentMessageProcessor.run(ConcurrentMessageProcessor.java:113)\n\tat java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:577)\n\tat java.base/java.util.concurrent.FutureTask.run(FutureTask.java:317)\n\tat java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)\n\tat java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)\n\tat java.base/java.lang.Thread.run(Thread.java:1623)\n"
  • 我尝试将我的jdk版本从最新更改为17
  • 我尝试手动安装 jdtls 并在没有 lsp 和 mason 插件的情况下配置它
java neovim
1个回答
0
投票

看起来 jdtls 在启动过程中崩溃了。

我在部分清理环境后遇到了这个问题。当 Jdtls 尝试加载已删除的 jar 并抛出上述错误时,它会崩溃。我通过清除 eclipse 缓存修复了它(

'-data', workspace_folder
输入 jdtls 命令就是位置)

对于进一步的根本原因,由于崩溃的是 jdtls 而不是 lsp,因此您需要在启动期间通过传入

'-Xlog::file=' .. home .. '/logs/test.log', '-verbose'
来获取 java 的日志输出。

© www.soinside.com 2019 - 2024. All rights reserved.