mfussenegger / nvim-jdtls

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

jdtls fails when opening.java file "WARNING: Using incubator modules: jdk.incubator.vector" #628

Closed MaxiLambda closed 4 months ago

MaxiLambda commented 4 months ago

LSP client configuration

local jdtls_setup = require('jdtls.setup')
--maybe add .git
local root_dir = jdtls_setup.find_root({ "pom.xml" })
local workspace_folder = "~/.local/share/eclipse/" .. vim.fn.fnamemodify(root_dir, ":p:h:t")

local extendedClientCapabilities = require("jdtls").extendedClientCapabilities
extendedClientCapabilities.resolveAdditionalTextEditsSupport = true
local jar = vim.fn.glob("~/.local/share/nvim/mason/packages/jdtls/plugins/org.eclipse.equinox.launcher_*.jar", false, false)
local lombok = "~/.local/share/nvim/mason/share/jdtls/lombok.jar"
local config = {
  settings = {
    java = {
      signatureHelp = { enabled = true },
      contentProvider = { preferred = "fernflower" },
      sources = {
        organizeImports = {
          starThreshold = 9999,
          staticStarThreshold = 9999,
        },
      },
      codeGeneration = {
        toString = {
          template = "${object.className}{${member.name()}=${member.value}, ${otherMembers}}",
        },
      },
      project = {
        referencedLibraries = {
          "**/lib/*.jar",
        },
      },
  --    configuration = {
  --      runtimes = {
  --        {
  --          name = "JavaSE-21",
  --          path = "~/.jdks/graalvm-jdk-21.0.2/"
  --        },
  --      },
  --    },
    },
  },
  flags = {
    allow_incremental_sync = true,
  },
  capabilities = require("cmp_nvim_lsp").default_capabilities(),
  on_attach = function()
    require("jdtls").setup_dap { hotcodereplace = "auto" }
    require("jdtls.dap").setup_dap_main_class_configs()
  end,
  --on_init = function(client)
  --  if client.config.settings then
  --    client.notify("workspace/didChangeConfiguration", { settings = client.config.settings })
  --  end
  --end,
  -- stylua: ignore
  cmd = {
    "java",
    "-Declipse.application=org.eclipse.jdt.ls.core.id1",
    "-Dosgi.bundles.defaultStartLevel=4",
    "-Declipse.product=org.eclipse.jdt.ls.core.product",
    "-Dlog.protocol=true",
    "-Dlog.level=ALL",
    "-Xms1G",
    "--add-modules=ALL-SYSTEM",
    "--add-opens", "java.base/java.util=ALL-UNNAMED",
    "--add-opens", "java.base/java.lang=ALL-UNNAMED",
    "-jar", jar,
    "-configuration", "~/.local/share/nvim/mason/packages/jdtls/config_linux",
    "-data", workspace_folder,
    "-javaagent:" .. lombok,
    -- "-Xbootclasspath/a:" .. lombok,
  },
  root_dir = root_dir,
  init_options = {
    bundles = {
      vim.fn.glob("~/.local/share/nvim/mason/packages/java-debug-adapter/extension/server/com.microsoft.java.debug.plugin-*.jar"),
    },
    extendedClientCapabilities = extendedClientCapabilities,
  },
}
require("jdtls").start_or_attach(config)

Eclipse.jdt.ls version

1.33.0

Steps to Reproduce

Download using mason. Setup the jdtls configuration in "after/ftplugin/java.lua".

Start nvim on java project with pom.xml in root dir Open a .java file

Expected Result

The server starts and attaches.

Actual Result

The server does not attach. A Message "Client jdtls quit with exit code 13 and signal 0"

Output from :LspLog

[START][2024-02-24 16:23:21] LSP logging initiated [ERROR][2024-02-24 16:23:21] .../vim/lsp/rpc.lua:796 "rpc" "java" "stderr" "WARNING: Using incubator modules: jdk.incubator.vector\n"

MaxiLambda commented 4 months ago

I also tried starting the server with active "configuration" section. I also deleted my .cache/jdtls files as recommended in another issue thread.

MaxiLambda commented 4 months ago

I fixed the issue. I used ~ to access the home dir. local home = os.getenv('HOME') works