Skip to content
This repository was archived by the owner on Oct 13, 2021. It is now read-only.
This repository was archived by the owner on Oct 13, 2021. It is now read-only.

LSP completion stops working after restarting the server #159

@fsouza

Description

@fsouza

The problem is that the code relies on #vim.lsp.buf_get_clients(), but vim.lsp.buf_get_clients() is an associative table and that operator doesn't work for that kind of table.

How to reproduce:

  • open a file with lsp enabled + completion-nvim
  • use completion
  • Stop all clients: :lua vim.lsp.stop_client(vim.lsp.get_active_clients())
  • Make the server restart by re-editing the file :e!
  • Try to use completion

Some debugging information:

After restarting, here's the output of print(vim.inspect(vim.lsp.buf_get_clients())):

{
  [3] = {
    _on_attach = <function 1>,
    callbacks = <1>{
      ["textDocument/declaration"] = <function 2>,
      ["textDocument/definition"] = <function 2>,
      ["textDocument/documentHighlight"] = <function 3>,
      ["textDocument/documentSymbol"] = <function 4>,
      ["textDocument/hover"] = <function 5>,
      ["textDocument/implementation"] = <function 2>,
      ["textDocument/publishDiagnostics"] = <function 6>,
      ["textDocument/references"] = <function 7>,
      ["textDocument/typeDefinition"] = <function 2>,
      ["window/logMessage"] = <function 8>,
      ["window/showMessage"] = <function 9>,
      ["workspace/configuration"] = <function 10>,
      ["workspace/symbol"] = <function 4>,
      <metatable> = <2>{
        __tostring = <function 11>
      }
    },
    cancel_request = <function 12>,
    config = {
      _on_attach = <function 13>,
      callbacks = <table 1>,
      capabilities = {
        callHierarchy = {
          dynamicRegistration = false,
          <metatable> = <table 2>
        },
        textDocument = {
          codeAction = {
            codeActionLiteralSupport = {
              codeActionKind = {
                valueSet = {},
                <metatable> = <table 2>
              },
              <metatable> = <table 2>
            },
            dynamicRegistration = false,
            <metatable> = <table 2>
          },
          completion = {
            completionItem = {
              commitCharactersSupport = false,
              deprecatedSupport = false,
              documentationFormat = { "markdown", "plaintext" },
              preselectSupport = false,
              snippetSupport = false,
              <metatable> = <table 2>
            ...

Notice how the key is [3].

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions