Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error executing vim.schedule lua callback: **/lsp/handlers.lua:122 bad argument #1 to 'ipairs' (table expected, got nil) #267

Open
arbitrary-dev opened this issue Aug 11, 2023 · 6 comments

Comments

@arbitrary-dev
Copy link

Trying to go through Spring Quickstart, but getting this error:

Error executing vim.schedule lua callback: /usr/share/nvim/runtime/lua/vim/lsp/handlers.lua:122: bad argument #1 to 'ipairs' (table expected, got nil)
stack traceback:
        [C]: in function 'ipairs'
        /usr/share/nvim/runtime/lua/vim/lsp/handlers.lua:122: in function 'handler'
        /usr/share/nvim/runtime/lua/vim/lsp.lua:1057: in function ''
        vim/_editor.lua: in function <vim/_editor.lua:0>

**/lsp/handlers.lua:122

--see: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#client_registerCapability
M['client/registerCapability'] = function(_, result, ctx)
  local log_unsupported = false
  for _, reg in ipairs(result.registrations) do ------------------------- Line #122
    if reg.method == 'workspace/didChangeWatchedFiles' then
      require('vim.lsp._watchfiles').register(reg, ctx)
    else
      log_unsupported = true
    end
  end
  if log_unsupported then
    local client_id = ctx.client_id
    local warning_tpl = 'The language server %s triggers a registerCapability '
      .. 'handler despite dynamicRegistration set to false. '
      .. 'Report upstream, this warning is harmless'
    local client = vim.lsp.get_client_by_id(client_id)
    local client_name = client and client.name or string.format('id=%d', client_id)
    local warning = string.format(warning_tpl, client_name)
    log.warn(warning)
  end
  return vim.NIL
end

Setup

local lspcfg = require "lspconfig"
vim.lsp.set_log_level("debug")
lspcfg.java_language_server.setup { cmd = {"java-language-server"} }

:LspLog

lsp.log

@yimingwangdell
Copy link

same issue found....

@anthony-S93
Copy link

anthony-S93 commented Sep 13, 2023

Same issue in java-language-server version 0.2.39-1.

lsp.log:

[START][2023-09-14 00:49:20] LSP logging initiated
[INFO][2023-09-14 00:49:20] .../vim/lsp/rpc.lua:662	"Starting RPC client"	{  args = {},  cmd = "/usr/share/java/java-language-server/lang_server_linux.sh",  extra = {    cwd = "/home/anthony93/Devfiles/learning/cpama"  }}
[DEBUG][2023-09-14 00:49:20] .../vim/lsp/rpc.lua:284	"rpc.send"	{  id = 1,  jsonrpc = "2.0",  method = "initialize",  params = {    capabilities = {      textDocument = {        callHierarchy = {          dynamicRegistration = false        },        codeAction = {          codeActionLiteralSupport = {            codeActionKind = {              valueSet = { "", "quickfix", "refactor", "refactor.extract", "refactor.inline", "refactor.rewrite", "source", "source.organizeImports" }            }          },          dataSupport = true,          dynamicRegistration = false,          isPreferredSupport = true,          resolveSupport = {            properties = { "edit" }          }        },        completion = {          completionItem = {            commitCharactersSupport = true,            deprecatedSupport = true,            documentationFormat = { "markdown", "plaintext" },            insertReplaceSupport = true,            insertTextModeSupport = {              valueSet = { 1, 2 }            },            labelDetailsSupport = true,            preselectSupport = true,            resolveSupport = {              properties = { "documentation", "detail", "additionalTextEdits", "sortText", "filterText", "insertText", "textEdit", "insertTextFormat", "insertTextMode" }            },            snippetSupport = true,            tagSupport = {              valueSet = { 1 }            }          },          completionItemKind = {            valueSet = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25 }          },          completionList = {            itemDefaults = { "commitCharacters", "editRange", "insertTextFormat", "insertTextMode", "data" }          },          contextSupport = true,          dynamicRegistration = false,          insertTextMode = 1        },        declaration = {          linkSupport = true        },        definition = {          linkSupport = true        },        documentHighlight = {          dynamicRegistration = false        },        documentSymbol = {          dynamicRegistration = false,          hierarchicalDocumentSymbolSupport = true,          symbolKind = {            valueSet = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26 }          }        },        hover = {          contentFormat = { "markdown", "plaintext" },          dynamicRegistration = false        },        implementation = {          linkSupport = true        },        publishDiagnostics = {          relatedInformation = true,          tagSupport = {            valueSet = { 1, 2 }          }        },        references = {          dynamicRegistration = false        },        rename = {          dynamicRegistration = false,          prepareSupport = true        },        semanticTokens = {          augmentsSyntaxTokens = true,          dynamicRegistration = false,          formats = { "relative" },          multilineTokenSupport = false,          overlappingTokenSupport = true,          requests = {            full = {              delta = true            },            range = false          },          serverCancelSupport = false,          tokenModifiers = { "declaration", "definition", "readonly", "static", "deprecated", "abstract", "async", "modification", "documentation", "defaultLibrary" },          tokenTypes = { "namespace", "type", "class", "enum", "interface", "struct", "typeParameter", "parameter", "variable", "property", "enumMember", "event", "function", "method", "macro", "keyword", "modifier", "comment", "string", "number", "regexp", "operator", "decorator" }        },        signatureHelp = {          dynamicRegistration = false,          signatureInformation = {            activeParameterSupport = true,            documentationFormat = { "markdown", "plaintext" },            parameterInformation = {              labelOffsetSupport = true            }          }        },        synchronization = {          didSave = true,          dynamicRegistration = false,          willSave = true,          willSaveWaitUntil = true        },        typeDefinition = {          linkSupport = true        }      },      window = {        showDocument = {          support = true        },        showMessage = {          messageActionItem = {            additionalPropertiesSupport = false          }        },        workDoneProgress = true      },      workspace = {        applyEdit = true,        configuration = true,        didChangeWatchedFiles = {          dynamicRegistration = true,          relativePatternSupport = true        },        semanticTokens = {          refreshSupport = true        },        symbol = {          dynamicRegistration = false,          hierarchicalWorkspaceSymbolSupport = true,          symbolKind = {            valueSet = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26 }          }        },        workspaceEdit = {          resourceOperations = { "rename", "create", "delete" }        },        workspaceFolders = true      }    },    clientInfo = {      name = "Neovim",      version = "0.9.2"    },    initializationOptions = vim.empty_dict(),    processId = 506443,    rootPath = "/home/anthony93/Devfiles/learning/cpama",    rootUri = "file:///home/anthony93/Devfiles/learning/cpama",    trace = "off",    workspaceFolders = { {        name = "/home/anthony93/Devfiles/learning/cpama",        uri = "file:///home/anthony93/Devfiles/learning/cpama"      } }  }}
[ERROR][2023-09-14 00:49:20] .../vim/lsp/rpc.lua:734	"rpc"	"/usr/share/java/java-language-server/lang_server_linux.sh"	"stderr"	"00:49:20.475\tINFO\tLSP connect\tReading messages from queue...\n"
[ERROR][2023-09-14 00:49:20] .../vim/lsp/rpc.lua:734	"rpc"	"/usr/share/java/java-language-server/lang_server_linux.sh"	"stderr"	"00:49:20.475\tINFO\tLSP$1MessageReader run\tPlacing incoming messages on queue...\n"
[DEBUG][2023-09-14 00:49:20] .../vim/lsp/rpc.lua:387	"rpc.receive"	{  id = 1,  jsonrpc = "2.0",  result = {    capabilities = {      codeActionProvider = true,      codeLensProvider = vim.empty_dict(),      completionProvider = {        resolveProvider = true,        triggerCharacters = { "." }      },      definitionProvider = true,      documentFormattingProvider = true,      documentSymbolProvider = true,      foldingRangeProvider = true,      hoverProvider = true,      referencesProvider = true,      renameProvider = {        prepareProvider = true      },      signatureHelpProvider = {        triggerCharacters = { "(", "," }      },      textDocumentSync = 2,      workspaceSymbolProvider = true    }  }}
[DEBUG][2023-09-14 00:49:20] .../vim/lsp/rpc.lua:284	"rpc.send"	{  jsonrpc = "2.0",  method = "initialized",  params = vim.empty_dict()}
[INFO][2023-09-14 00:49:20] .../lua/vim/lsp.lua:1344	"LSP[java_language_server]"	"server_capabilities"	{  server_capabilities = {    codeActionProvider = true,    codeLensProvider = vim.empty_dict(),    completionProvider = {      resolveProvider = true,      triggerCharacters = { "." }    },    definitionProvider = true,    documentFormattingProvider = true,    documentSymbolProvider = true,    foldingRangeProvider = true,    hoverProvider = true,    referencesProvider = true,    renameProvider = {      prepareProvider = true    },    signatureHelpProvider = {      triggerCharacters = { "(", "," }    },    textDocumentSync = {      change = 2,      openClose = true,      save = {        includeText = false      },      willSave = false,      willSaveWaitUntil = false    },    workspaceSymbolProvider = true  }}
[DEBUG][2023-09-14 00:49:20] .../vim/lsp/rpc.lua:284	"rpc.send"	{  jsonrpc = "2.0",  method = "textDocument/didOpen",  params = {    textDocument = {      languageId = "java",      text = "\n",      uri = "file:///home/anthony93/Devfiles/learning/cpama/test.java",      version = 0    }  }}
[DEBUG][2023-09-14 00:49:20] .../vim/lsp/rpc.lua:387	"rpc.receive"	{  jsonrpc = "2.0",  method = "client/registerCapability",  params = {    id = "6803a8f4-fb83-46f1-817b-4d23b8deccc2",    method = "workspace/didChangeWatchedFiles",    registerOptions = {      watchers = { {          globPattern = "**/*.java"        }, {          globPattern = "**/pom.xml"        }, {          globPattern = "**/BUILD"        } }    }  }}
[ERROR][2023-09-14 00:49:20] .../vim/lsp/rpc.lua:734	"rpc"	"/usr/share/java/java-language-server/lang_server_linux.sh"	"stderr"	"00:49:20.767\tINFO\tJavaLanguageServer lint\tLint 1 files...\n"
[DEBUG][2023-09-14 00:49:20] .../vim/lsp/rpc.lua:387	"rpc.receive"	{  jsonrpc = "2.0",  method = "java/startProgress",  params = {    message = "Configure javac"  }}
[DEBUG][2023-09-14 00:49:20] .../vim/lsp/rpc.lua:387	"rpc.receive"	{  jsonrpc = "2.0",  method = "java/reportProgress",  params = {    increment = -1,    message = "Finding source roots"  }}
[DEBUG][2023-09-14 00:49:20] .../vim/lsp/rpc.lua:387	"rpc.receive"	{  jsonrpc = "2.0",  method = "java/reportProgress",  params = {    increment = -1,    message = "Inferring class path"  }}
[DEBUG][2023-09-14 00:49:20] .../vim/lsp/rpc.lua:387	"rpc.receive"	{  jsonrpc = "2.0",  method = "java/reportProgress",  params = {    increment = -1,    message = "Inferring doc path"  }}
[DEBUG][2023-09-14 00:49:20] .../vim/lsp/rpc.lua:387	"rpc.receive"	{  jsonrpc = "2.0",  method = "java/endProgress"}
[ERROR][2023-09-14 00:49:20] .../vim/lsp/rpc.lua:734	"rpc"	"/usr/share/java/java-language-server/lang_server_linux.sh"	"stderr"	"00:49:20.776\tINFO\tScanClassPath jdkTopLevelClasses\tSearching for top-level classes in the JDK\n"
[ERROR][2023-09-14 00:49:20] .../vim/lsp/rpc.lua:734	"rpc"	"/usr/share/java/java-language-server/lang_server_linux.sh"	"stderr"	"00:49:20.869\tINFO\tScanClassPath jdkTopLevelClasses\tFound 5946 classes in the java platform\n"
[ERROR][2023-09-14 00:49:20] .../vim/lsp/rpc.lua:734	"rpc"	"/usr/share/java/java-language-server/lang_server_linux.sh"	"stderr"	"Class path:\nDoc path:\n"
[ERROR][2023-09-14 00:49:20] .../vim/lsp/rpc.lua:734	"rpc"	"/usr/share/java/java-language-server/lang_server_linux.sh"	"stderr"	"00:49:20.917\tWARNING\tDocs findSrcZip\tCouldn't find src.zip in /usr/lib/jvm/default-runtime\n"
[ERROR][2023-09-14 00:49:20] .../vim/lsp/rpc.lua:734	"rpc"	"/usr/share/java/java-language-server/lang_server_linux.sh"	"stderr"	"00:49:20.918\tINFO\tScanClassPath classPathTopLevelClasses\tSearching for top-level classes in 0 classpath locations\n"
[ERROR][2023-09-14 00:49:20] .../vim/lsp/rpc.lua:734	"rpc"	"/usr/share/java/java-language-server/lang_server_linux.sh"	"stderr"	"00:49:20.922\tINFO\tScanClassPath classPathTopLevelClasses\tFound 0 classes in classpath\n"
[ERROR][2023-09-14 00:49:20] .../vim/lsp/rpc.lua:734	"rpc"	"/usr/share/java/java-language-server/lang_server_linux.sh"	"stderr"	"00:49:20.925\tWARNING\tReusableCompiler getTask\tOptions changed from [-classpath, , --add-modules, ALL-MODULE-PATH, -proc:none, -g, -Xlint:cast, -Xlint:deprecation, -Xlint:empty, -Xlint:fallthrough, -Xlint:finally, -Xlint:path, -Xlint:unchecked, -Xlint:varargs, -Xlint:static] to [-classpath, , --add-modules, ALL-MODULE-PATH, -proc:none, -g, -Xlint:cast, -Xlint:deprecation, -Xlint:empty, -Xlint:fallthrough, -Xlint:finally, -Xlint:path, -Xlint:unchecked, -Xlint:varargs, -Xlint:static], creating new compiler\n"
[ERROR][2023-09-14 00:49:21] .../vim/lsp/rpc.lua:734	"rpc"	"/usr/share/java/java-language-server/lang_server_linux.sh"	"stderr"	"00:49:21.153\tINFO\tJavaLanguageServer lint\t...compiled in 381 ms\n"
[DEBUG][2023-09-14 00:49:21] .../vim/lsp/rpc.lua:387	"rpc.receive"	{  jsonrpc = "2.0",  method = "textDocument/publishDiagnostics",  params = {    diagnostics = {},    uri = "file:///home/anthony93/Devfiles/learning/cpama/test.java"  }}
[DEBUG][2023-09-14 00:49:21] .../vim/lsp/rpc.lua:387	"rpc.receive"	{  jsonrpc = "2.0",  method = "java/colors",  params = {    fields = {},    statics = {},    uri = "file:///home/anthony93/Devfiles/learning/cpama/test.java"  }}
[ERROR][2023-09-14 00:49:21] .../vim/lsp/rpc.lua:734	"rpc"	"/usr/share/java/java-language-server/lang_server_linux.sh"	"stderr"	"00:49:21.160\tINFO\tJavaLanguageServer lint\t...published in 392 ms\n"
[START][2023-09-14 00:49:59] LSP logging initiated
[INFO][2023-09-14 00:49:59] .../lua/vim/lsp.lua:1875	"exit_handler"	{}
[INFO][2023-09-14 00:50:02] .../lua/vim/lsp.lua:1875	"exit_handler"	{ {    _on_attach = <function 1>,    attached_buffers = { true },    cancel_request = <function 2>,    commands = {},    config = {      _on_attach = <function 3>,      autostart = true,      capabilities = {        textDocument = {          callHierarchy = {            dynamicRegistration = false          },          codeAction = {            codeActionLiteralSupport = {              codeActionKind = {                valueSet = { "", "quickfix", "refactor", "refactor.extract", "refactor.inline", "refactor.rewrite", "source", "source.organizeImports" }              }            },            dataSupport = true,            dynamicRegistration = false,            isPreferredSupport = true,            resolveSupport = {              properties = { "edit" }            }          },          completion = {            completionItem = {              commitCharactersSupport = true,              deprecatedSupport = true,              documentationFormat = { "markdown", "plaintext" },              insertReplaceSupport = true,              insertTextModeSupport = {                valueSet = { 1, 2 }              },              labelDetailsSupport = true,              preselectSupport = true,              resolveSupport = {                properties = { "documentation", "detail", "additionalTextEdits", "sortText", "filterText", "insertText", "textEdit", "insertTextFormat", "insertTextMode" }              },              snippetSupport = true,              tagSupport = {                valueSet = { 1 }              }            },            completionItemKind = {              valueSet = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25 }            },            completionList = {              itemDefaults = { "commitCharacters", "editRange", "insertTextFormat", "insertTextMode", "data" }            },            contextSupport = true,            dynamicRegistration = false,            insertTextMode = 1          },          declaration = {            linkSupport = true          },          definition = {            linkSupport = true          },          documentHighlight = {            dynamicRegistration = false          },          documentSymbol = {            dynamicRegistration = false,            hierarchicalDocumentSymbolSupport = true,            symbolKind = {              valueSet = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26 }            }          },          hover = {            contentFormat = { "markdown", "plaintext" },            dynamicRegistration = false          },          implementation = {            linkSupport = true          },          publishDiagnostics = {            relatedInformation = true,            tagSupport = {              valueSet = { 1, 2 }            }          },          references = {            dynamicRegistration = false          },          rename = {            dynamicRegistration = false,            prepareSupport = true          },          semanticTokens = {            augmentsSyntaxTokens = true,            dynamicRegistration = false,            formats = { "relative" },            multilineTokenSupport = false,            overlappingTokenSupport = true,            requests = {              full = {                delta = true              },              range = false            },            serverCancelSupport = false,            tokenModifiers = { "declaration", "definition", "readonly", "static", "deprecated", "abstract", "async", "modification", "documentation", "defaultLibrary" },            tokenTypes = { "namespace", "type", "class", "enum", "interface", "struct", "typeParameter", "parameter", "variable", "property", "enumMember", "event", "function", "method", "macro", "keyword", "modifier", "comment", "string", "number", "regexp", "operator", "decorator" }          },          signatureHelp = {            dynamicRegistration = false,            signatureInformation = {              activeParameterSupport = true,              documentationFormat = { "markdown", "plaintext" },              parameterInformation = {                labelOffsetSupport = true              }            }          },          synchronization = {            didSave = true,            dynamicRegistration = false,            willSave = true,            willSaveWaitUntil = true          },          typeDefinition = {            linkSupport = true          }        },        window = {          showDocument = {            support = true          },          showMessage = {            messageActionItem = {              additionalPropertiesSupport = false            }          },          workDoneProgress = true        },        workspace = {          applyEdit = true,          configuration = true,          didChangeWatchedFiles = {            dynamicRegistration = true,            relativePatternSupport = true          },          semanticTokens = {            refreshSupport = true          },          symbol = {            dynamicRegistration = false,            hierarchicalWorkspaceSymbolSupport = true,            symbolKind = {              valueSet = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26 }            }          },          workspaceEdit = {            resourceOperations = { "rename", "create", "delete" }          },          workspaceFolders = true        }      },      cmd = { "/usr/share/java/java-language-server/lang_server_linux.sh" },      cmd_cwd = "/home/anthony93/Devfiles/learning/cpama",      filetypes = { "java" },      flags = {},      get_language_id = <function 4>,      handlers = <1>{},      init_options = vim.empty_dict(),      log_level = 2,      message_level = 2,      name = "java_language_server",      on_attach = <function 5>,      on_exit = <function 6>,      on_init = <function 7>,      root_dir = "/home/anthony93/Devfiles/learning/cpama",      settings = {},      workspace_folders = <2>{ {          name = "/home/anthony93/Devfiles/learning/cpama",          uri = "file:///home/anthony93/Devfiles/learning/cpama"        } },      <metatable> = <3>{        __tostring = <function 8>      }    },    handlers = <table 1>,    id = 1,    initialized = true,    is_stopped = <function 9>,    messages = {      messages = {},      name = "java_language_server",      progress = {},      status = {}    },    name = "java_language_server",    notify = <function 10>,    offset_encoding = "utf-16",    request = <function 11>,    request_sync = <function 12>,    requests = {},    rpc = {      is_closing = <function 13>,      notify = <function 14>,      request = <function 15>,      terminate = <function 16>    },    server_capabilities = {      codeActionProvider = true,      codeLensProvider = vim.empty_dict(),      completionProvider = {        resolveProvider = true,        triggerCharacters = { "." }      },      definitionProvider = true,      documentFormattingProvider = true,      documentSymbolProvider = true,      foldingRangeProvider = true,      hoverProvider = true,      referencesProvider = true,      renameProvider = {        prepareProvider = true      },      signatureHelpProvider = {        triggerCharacters = { "(", "," }      },      textDocumentSync = {        change = 2,        openClose = true,        save = {          includeText = false        },        willSave = false,        willSaveWaitUntil = false      },      workspaceSymbolProvider = true    },    stop = <function 17>,    supports_method = <function 18>,    workspace_did_change_configuration = <function 19>,    workspace_folders = <table 2>  } }
[DEBUG][2023-09-14 00:50:02] .../vim/lsp/rpc.lua:284	"rpc.send"	{  id = 2,  jsonrpc = "2.0",  method = "shutdown"}
[ERROR][2023-09-14 00:50:02] .../vim/lsp/rpc.lua:734	"rpc"	"/usr/share/java/java-language-server/lang_server_linux.sh"	"stderr"	"00:50:02.524\tWARNING\tLSP connect\tGot shutdown message\n"
[DEBUG][2023-09-14 00:50:02] .../vim/lsp/rpc.lua:387	"rpc.receive"	{  id = 2,  jsonrpc = "2.0"}
[DEBUG][2023-09-14 00:50:02] .../vim/lsp/rpc.lua:284	"rpc.send"	{  jsonrpc = "2.0",  method = "exit"}

@A-Committed-Dev
Copy link

You guys ever found a solution? sitting with the same problem.

@anthony-S93
Copy link

anthony-S93 commented Sep 27, 2023

You guys ever found a solution? sitting with the same problem.

Unfortunately, I didn't have the time to look into it. In the end, I got fed up and switched to jdtls.

@npavlicek
Copy link

Used Mason to install java-language-server on nvim and I get this same error every time I launch

@thatsmydoing
Copy link

I believe this PR should fix it #262

The client/registerCapability call was non-standard which is why it broke in nvim.

To work around this, you can add the following to the LSP config

    handlers = {
      ['client/registerCapability'] = function(err, result, ctx, config)
        local registration = {
          registrations = { result },
        }
        return vim.lsp.handlers['client/registerCapability'](err, registration, ctx, config)
      end
    },

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants