mfussenegger / nvim-jdtls

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

Undefined variable exception during startup #643

Open SafinWasi opened 6 months ago

SafinWasi commented 6 months ago

LSP client configuration

local config = {
    -- The command that starts the language server
    -- See: https://github.com/eclipse/eclipse.jdt.ls#running-from-the-command-line
    cmd = {

      -- 💀
      'java', -- or '/path/to/java17_or_newer/bin/java'
      -- depends on if `java` is in your $PATH env variable and if it points to the right version.

      '-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',
      '-Xmx1g',
      '--add-modules=ALL-SYSTEM',
      '--add-opens', 'java.base/java.util=ALL-UNNAMED',
      '--add-opens', 'java.base/java.lang=ALL-UNNAMED',

      '-jar', path_to_jdtls .. '/plugins/org.eclipse.equinox.launcher_1.6.700.v20231214-2017.jar',

      '-configuration', path_to_config,

      '-data', workspace_dir
    },

    -- Here you can configure eclipse.jdt.ls specific settings
    -- See https://github.com/eclipse/eclipse.jdt.ls/wiki/Running-the-JAVA-LS-server-from-the-command-line#initialize-request
    -- for a list of options
    settings = {
      java = {
      }
    },

    -- Language server `initializationOptions`
    -- You need to extend the `bundles` with paths to jar files
    -- if you want to use additional eclipse.jdt.ls plugins.
    --
    -- See https://github.com/mfussenegger/nvim-jdtls#java-debug-installation
    --
    -- If you don't plan on using the debugger or other eclipse.jdt.ls plugins you can remove this
    init_options = {
      bundles = {}
    },
  }

Eclipse.jdt.ls version

1.33.0

Steps to Reproduce

Opening a multi module maven project at the root (in this case https://github.com/JanssenProject/jans), I open a Java file and get this exception on the nvim console:

Cannot invoke
Error executing vim.schedule lua callback: ...si/.local/share/nvim/lazy/nvim-jdtls/lua/jdtls/setup.lua:13: Vim(echo):E121: Undefined variable: org
stack traceback:
        [C]: in function 'nvim_command'
        ...si/.local/share/nvim/lazy/nvim-jdtls/lua/jdtls/setup.lua:13: in function 'handler'
        /usr/share/nvim/runtime/lua/vim/lsp.lua:1056: in function ''
        vim/_editor.lua: in function <vim/_editor.lua:0>

image

Expected Result

JDTLS should start normally

Actual Result

After hitting Enter, jdtls proceeds as normal and starts properly. This bug does not cause any other side effects.

mfussenegger commented 1 week ago

The error appears to be coming from the status notifications but I can't reproduce is.

As a workaround you could simply mute the notifications:

config.handlers['language/status'] = function() end