lsp-mode icon indicating copy to clipboard operation
lsp-mode copied to clipboard

go-lsp commands timing out with gopls

Open pierre-fastly opened this issue 3 years ago • 1 comments

Thank you for the bug report

  • [X] I am using the latest version of lsp-mode related packages.
  • [X] I checked FAQ and Troubleshooting sections
  • [ ] You may also try reproduce the issue using clean environment using the following command: M-x lsp-start-plain

Bug description

When opening a golang file, I don't get any goodness coming with lsp: no hover, no syntax checking, nothing. Trying to save the file results in the UI freezing for ~10 seconds until a timeout occurs. Looking into this further, looks like all commands sent to the gopls binary are timing out.

Also, when trying to restart the gopls server through lsp-workspace-restart, I get a weird error Lisp error: (wrong-type-argument consp nil). I copied the full stacktrace further down.

Steps to reproduce

  1. Open a golang file, run lsp
  2. See no lsp commands are available and blocking commands freeze the UI until a timeout occurs.
  3. Restart the workspace with lsp-workspace-restart
  4. See the error appear

Expected behavior

No UI freezing, hover and syntax checking should work, no error when restarting lsp.

Which Language Server did you use?

lsp-go

OS

MacOS

Error callstack

`stacktrace`:

Debugger entered--Lisp error: (wrong-type-argument consp nil)
  lsp--make-message((:jsonrpc "2.0" :id 2 :result [#<hash-table equal 12/65 0x1ff3bea80729>]))
  lsp--send-request-response(#s(lsp--workspace :ewoc nil :server-capabilities #<hash-table equal 22/22 0x1ff3bc14c331> :registered-server-capabilities nil :root "/Users/pierre/go/src/github.com/signalsciences/sig..." :client #s(lsp--client :language-id "go" :add-on? nil :new-connection (:connect #f(compiled-function (filter sentinel name environment-fn) #<bytecode -0x129eafa2849a042c>) :test\? #f(compiled-function () #<bytecode 0x2348e83346c0693>)) :ignore-regexps nil :ignore-messages nil :notification-handlers #<hash-table equal 0/65 0x1ff3bdec2057> :request-handlers #<hash-table equal 0/65 0x1ff3bdeb8435> :response-handlers #<hash-table eql 13/97 0x1ff3bdeb8455> :prefix-function nil :uri-handlers #<hash-table equal 0/65 0x1ff3bdeb7035> :action-handlers #<hash-table equal 0/65 0x1ff3bdeb7055> :major-modes (go-mode go-dot-mod-mode) :activation-fn nil :priority 0 :server-id gopls :multi-root nil :initialization-options nil :semantic-tokens-faces-overrides nil :custom-capabilities nil :library-folders-fn lsp-go--library-default-directories :before-file-open-fn nil :initialized-fn nil :remote? nil :completion-in-comments? t :path->uri-fn nil :uri->path-fn nil :environment-fn nil :after-open-fn #f(compiled-function () #<bytecode -0x1c580b33f5e6139e>) :async-request-handlers #<hash-table equal 0/65 0x1ff3bdeb4f35> :download-server-fn nil :download-in-progress? nil :buffers nil :synchronize-sections nil) :host-root nil :proc #<process gopls> :cmd-proc #<process gopls> :buffers (#<buffer siteservice_test.go>) :semantic-tokens-faces nil :semantic-tokens-modifier-faces nil :extra-client-capabilities nil :status initialized :metadata #<hash-table equal 0/65 0x1ff3b3e3826b> :watches #<hash-table equal 0/65 0x1ff3b059a89b> :workspace-folders nil :last-id 0 :status-string nil :shutdown-action nil :diagnostics #<hash-table equal 0/65 0x1ff3b059a8bb> :work-done-tokens #<hash-table equal 1/65 0x1ff3ae531085>) (25362 16684 348159 0) #<hash-table equal 4/4 0x1ff3beabb127> [#<hash-table equal 12/65 0x1ff3bea80729>])
  lsp--on-request(#s(lsp--workspace :ewoc nil :server-capabilities #<hash-table equal 22/22 0x1ff3bc14c331> :registered-server-capabilities nil :root "/Users/pierre/go/src/github.com/signalsciences/sig..." :client #s(lsp--client :language-id "go" :add-on? nil :new-connection (:connect #f(compiled-function (filter sentinel name environment-fn) #<bytecode -0x129eafa2849a042c>) :test\? #f(compiled-function () #<bytecode 0x2348e83346c0693>)) :ignore-regexps nil :ignore-messages nil :notification-handlers #<hash-table equal 0/65 0x1ff3bdec2057> :request-handlers #<hash-table equal 0/65 0x1ff3bdeb8435> :response-handlers #<hash-table eql 13/97 0x1ff3bdeb8455> :prefix-function nil :uri-handlers #<hash-table equal 0/65 0x1ff3bdeb7035> :action-handlers #<hash-table equal 0/65 0x1ff3bdeb7055> :major-modes (go-mode go-dot-mod-mode) :activation-fn nil :priority 0 :server-id gopls :multi-root nil :initialization-options nil :semantic-tokens-faces-overrides nil :custom-capabilities nil :library-folders-fn lsp-go--library-default-directories :before-file-open-fn nil :initialized-fn nil :remote? nil :completion-in-comments? t :path->uri-fn nil :uri->path-fn nil :environment-fn nil :after-open-fn #f(compiled-function () #<bytecode -0x1c580b33f5e6139e>) :async-request-handlers #<hash-table equal 0/65 0x1ff3bdeb4f35> :download-server-fn nil :download-in-progress? nil :buffers nil :synchronize-sections nil) :host-root nil :proc #<process gopls> :cmd-proc #<process gopls> :buffers (#<buffer siteservice_test.go>) :semantic-tokens-faces nil :semantic-tokens-modifier-faces nil :extra-client-capabilities nil :status initialized :metadata #<hash-table equal 0/65 0x1ff3b3e3826b> :watches #<hash-table equal 0/65 0x1ff3b059a89b> :workspace-folders nil :last-id 0 :status-string nil :shutdown-action nil :diagnostics #<hash-table equal 0/65 0x1ff3b059a8bb> :work-done-tokens #<hash-table equal 1/65 0x1ff3ae531085>) #<hash-table equal 4/4 0x1ff3beabb127>)
  lsp--parser-on-message(#<hash-table equal 4/4 0x1ff3beabb127> #s(lsp--workspace :ewoc nil :server-capabilities #<hash-table equal 22/22 0x1ff3bc14c331> :registered-server-capabilities nil :root "/Users/pierre/go/src/github.com/signalsciences/sig..." :client #s(lsp--client :language-id "go" :add-on? nil :new-connection (:connect #f(compiled-function (filter sentinel name environment-fn) #<bytecode -0x129eafa2849a042c>) :test\? #f(compiled-function () #<bytecode 0x2348e83346c0693>)) :ignore-regexps nil :ignore-messages nil :notification-handlers #<hash-table equal 0/65 0x1ff3bdec2057> :request-handlers #<hash-table equal 0/65 0x1ff3bdeb8435> :response-handlers #<hash-table eql 13/97 0x1ff3bdeb8455> :prefix-function nil :uri-handlers #<hash-table equal 0/65 0x1ff3bdeb7035> :action-handlers #<hash-table equal 0/65 0x1ff3bdeb7055> :major-modes (go-mode go-dot-mod-mode) :activation-fn nil :priority 0 :server-id gopls :multi-root nil :initialization-options nil :semantic-tokens-faces-overrides nil :custom-capabilities nil :library-folders-fn lsp-go--library-default-directories :before-file-open-fn nil :initialized-fn nil :remote? nil :completion-in-comments? t :path->uri-fn nil :uri->path-fn nil :environment-fn nil :after-open-fn #f(compiled-function () #<bytecode -0x1c580b33f5e6139e>) :async-request-handlers #<hash-table equal 0/65 0x1ff3bdeb4f35> :download-server-fn nil :download-in-progress? nil :buffers nil :synchronize-sections nil) :host-root nil :proc #<process gopls> :cmd-proc #<process gopls> :buffers (#<buffer siteservice_test.go>) :semantic-tokens-faces nil :semantic-tokens-modifier-faces nil :extra-client-capabilities nil :status initialized :metadata #<hash-table equal 0/65 0x1ff3b3e3826b> :watches #<hash-table equal 0/65 0x1ff3b059a89b> :workspace-folders nil :last-id 0 :status-string nil :shutdown-action nil :diagnostics #<hash-table equal 0/65 0x1ff3b059a8bb> :work-done-tokens #<hash-table equal 1/65 0x1ff3ae531085>))
  #f(compiled-function (msg) #<bytecode -0x1655063ce2b16a5f>)(#<hash-table equal 4/4 0x1ff3beabb127>)
  mapc(#f(compiled-function (msg) #<bytecode -0x1655063ce2b16a5f>) (#<hash-table equal 4/4 0x1ff3beabb127>))
  #f(compiled-function (proc input) #<bytecode -0x1007efd628efb1f0>)(#<process gopls> "Content-Length: 174\15\n\15\n{\"jsonrpc\":\"2.0\",\"method\":\"...")

*lsp-log*:

Command "golangci-lint-langserver" is present on the path.
Command "gopls -remote=auto" is present on the path.
Command "golangci-lint-langserver" is present on the path.
Command "gopls -remote=auto" is present on the path.
Found the following clients for /Users/pierre/go/src/github.com/signalsciences/sigsci/testing/integration/siteservice_test.go: (server-id golangci-lint, priority 0), (server-id gopls, priority 0)
The following clients were selected based on priority: (server-id gopls, priority 0), (server-id golangci-lint, priority 0)
2022/09/02 11:34:00 Handshake session update
	update_session=12
	debug_address=""
	logfile=""
	server="1"
	gopls_path="/usr/local/bin/gopls"

Cancelling textDocument/codeAction(10295) in hook post-command-hook
Cancelling textDocument/documentLink(10293) in hook post-command-hook

lsp-workspace-show-log output (file and its content redacted):

[Trace - 11:39:43 AM] Sending request 'initialize - (123)'.
Params: {
  "processId": null,
  "rootPath": "/Users/ibizaman/go/src/github.com/my/repo",
  "clientInfo": {
    "name": "emacs",
    "version": "GNU Emacs 28.1 (build 2, x86_64-apple-darwin21.5.0, NS appkit-2113.50 Version 12.4 (Build 21F79))\n of 2022-08-11"
  },
  "rootUri": "file:///Users/ibizaman/go/src/github.com/my/repo",
  "capabilities": {
    "workspace": {
      "workspaceEdit": {
        "documentChanges": true,
        "resourceOperations": [
          "create",
          "rename",
          "delete"
        ]
      },
      "applyEdit": true,
      "symbol": {
        "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
          ]
        }
      },
      "executeCommand": {
        "dynamicRegistration": false
      },
      "didChangeWatchedFiles": {
        "dynamicRegistration": true
      },
      "workspaceFolders": true,
      "configuration": true,
      "codeLens": {
        "refreshSupport": true
      },
      "fileOperations": {
        "didCreate": false,
        "willCreate": false,
        "didRename": true,
        "willRename": true,
        "didDelete": false,
        "willDelete": false
      }
    },
    "textDocument": {
      "declaration": {
        "dynamicRegistration": true,
        "linkSupport": true
      },
      "definition": {
        "dynamicRegistration": true,
        "linkSupport": true
      },
      "implementation": {
        "dynamicRegistration": true,
        "linkSupport": true
      },
      "typeDefinition": {
        "dynamicRegistration": true,
        "linkSupport": true
      },
      "synchronization": {
        "willSave": true,
        "didSave": true,
        "willSaveWaitUntil": true
      },
      "documentSymbol": {
        "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
          ]
        },
        "hierarchicalDocumentSymbolSupport": true
      },
      "formatting": {
        "dynamicRegistration": true
      },
      "rangeFormatting": {
        "dynamicRegistration": true
      },
      "onTypeFormatting": {
        "dynamicRegistration": true
      },
      "rename": {
        "dynamicRegistration": true,
        "prepareSupport": true
      },
      "codeAction": {
        "dynamicRegistration": true,
        "isPreferredSupport": true,
        "codeActionLiteralSupport": {
          "codeActionKind": {
            "valueSet": [
              "",
              "quickfix",
              "refactor",
              "refactor.extract",
              "refactor.inline",
              "refactor.rewrite",
              "source",
              "source.organizeImports"
            ]
          }
        },
        "resolveSupport": {
          "properties": [
            "edit",
            "command"
          ]
        },
        "dataSupport": true
      },
      "completion": {
        "completionItem": {
          "snippetSupport": true,
          "documentationFormat": [
            "markdown",
            "plaintext"
          ],
          "resolveAdditionalTextEditsSupport": true,
          "insertReplaceSupport": true,
          "deprecatedSupport": true,
          "resolveSupport": {
            "properties": [
              "documentation",
              "detail",
              "additionalTextEdits",
              "command"
            ]
          },
          "insertTextModeSupport": {
            "valueSet": [
              1,
              2
            ]
          }
        },
        "contextSupport": true,
        "dynamicRegistration": true
      },
      "signatureHelp": {
        "signatureInformation": {
          "parameterInformation": {
            "labelOffsetSupport": true
          }
        },
        "dynamicRegistration": true
      },
      "documentLink": {
        "dynamicRegistration": true,
        "tooltipSupport": true
      },
      "hover": {
        "contentFormat": [
          "markdown",
          "plaintext"
        ],
        "dynamicRegistration": true
      },
      "foldingRange": {
        "dynamicRegistration": true
      },
      "selectionRange": {
        "dynamicRegistration": true
      },
      "callHierarchy": {
        "dynamicRegistration": false
      },
      "typeHierarchy": {
        "dynamicRegistration": true
      },
      "publishDiagnostics": {
        "relatedInformation": true,
        "tagSupport": {
          "valueSet": [
            1,
            2
          ]
        },
        "versionSupport": true
      },
      "linkedEditingRange": {
        "dynamicRegistration": true
      }
    },
    "window": {
      "workDoneProgress": true,
      "showDocument": {
        "support": true
      }
    }
  },
  "initializationOptions": null,
  "workDoneToken": "1"
}


[Trace - 11:39:43 AM] Received notification 'window/logMessage'.
Params: {
  "type": 3,
  "message": "2022/09/02 11:39:43 Handshake session update\n\tupdate_session=20\n\tdebug_address=\"\"\n\tlogfile=\"\"\n\tserver=\"1\"\n\tgopls_path=\"/usr/local/bin/gopls\"\n"
}


[Trace - 11:39:44 AM] Received response 'initialize - (123)' in 308ms.
Result: {
  "capabilities": {
    "textDocumentSync": {
      "change": 2,
      "openClose": true,
      "save": {}
    },
    "completionProvider": {
      "triggerCharacters": [
        "."
      ],
      "completionItem": {}
    },
    "hoverProvider": true,
    "signatureHelpProvider": {
      "triggerCharacters": [
        "(",
        ","
      ]
    },
    "definitionProvider": true,
    "typeDefinitionProvider": true,
    "implementationProvider": true,
    "referencesProvider": true,
    "documentHighlightProvider": true,
    "documentSymbolProvider": true,
    "codeActionProvider": {
      "codeActionKinds": [
        "quickfix",
        "refactor.extract",
        "refactor.rewrite",
        "source.fixAll",
        "source.organizeImports"
      ]
    },
    "codeLensProvider": {},
    "documentLinkProvider": {},
    "workspaceSymbolProvider": true,
    "documentFormattingProvider": true,
    "documentOnTypeFormattingProvider": {
      "firstTriggerCharacter": ""
    },
    "renameProvider": {
      "prepareProvider": true
    },
    "foldingRangeProvider": true,
    "executeCommandProvider": {
      "commands": [
        "gopls.add_dependency",
        "gopls.add_import",
        "gopls.apply_fix",
        "gopls.check_upgrades",
        "gopls.edit_go_directive",
        "gopls.gc_details",
        "gopls.generate",
        "gopls.generate_gopls_mod",
        "gopls.go_get_package",
        "gopls.list_imports",
        "gopls.list_known_packages",
        "gopls.regenerate_cgo",
        "gopls.remove_dependency",
        "gopls.run_tests",
        "gopls.run_vulncheck_exp",
        "gopls.start_debugging",
        "gopls.test",
        "gopls.tidy",
        "gopls.toggle_gc_details",
        "gopls.update_go_sum",
        "gopls.upgrade_dependency",
        "gopls.vendor"
      ]
    },
    "callHierarchyProvider": true,
    "workspace": {
      "workspaceFolders": {
        "supported": true,
        "changeNotifications": "workspace/didChangeWorkspaceFolders"
      }
    },
    "inlayHintProvider": {}
  },
  "serverInfo": {
    "name": "gopls",
    "version": "{\"GoVersion\":\"go1.19\",\"Path\":\"golang.org/x/tools/gopls\",\"Main\":{\"Path\":\"golang.org/x/tools/gopls\",\"Version\":\"(devel)\",\"Sum\":\"\",\"Replace\":null},\"Deps\":[{\"Path\":\"github.com/BurntSushi/toml\",\"Version\":\"v1.2.0\",\"Sum\":\"h1:Rt8g24XnyGTyglgET/PRUNlrUeu9F5L+7FilkXfZgs0=\",\"Replace\":null},{\"Path\":\"github.com/google/go-cmp\",\"Version\":\"v0.5.8\",\"Sum\":\"h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=\",\"Replace\":null},{\"Path\":\"github.com/sergi/go-diff\",\"Version\":\"v1.1.0\",\"Sum\":\"h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=\",\"Replace\":null},{\"Path\":\"golang.org/x/exp/typeparams\",\"Version\":\"v0.0.0-20220722155223-a9213eeb770e\",\"Sum\":\"h1:7Xs2YCOpMlNqSQSmrrnhlzBXIE/bpMecZplbLePTJvE=\",\"Replace\":null},{\"Path\":\"golang.org/x/mod\",\"Version\":\"v0.6.0-dev.0.20220419223038-86c51ed26bb4\",\"Sum\":\"h1:6zppjxzCulZykYSLyVDYbneBfbaBIQPYMevg0bEwv2s=\",\"Replace\":null},{\"Path\":\"golang.org/x/sync\",\"Version\":\"v0.0.0-20220722155255-886fb9371eb4\",\"Sum\":\"h1:uVc8UZUe6tr40fFVnUP5Oj+veunVezqYl9z7DYw9xzw=\",\"Replace\":null},{\"Path\":\"golang.org/x/sys\",\"Version\":\"v0.0.0-20220722155257-8c9f86f7a55f\",\"Sum\":\"h1:v4INt8xihDGvnrfjMDVXGxw9wrfxYyCjk0KbXjhR55s=\",\"Replace\":null},{\"Path\":\"golang.org/x/text\",\"Version\":\"v0.3.7\",\"Sum\":\"h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=\",\"Replace\":null},{\"Path\":\"golang.org/x/tools\",\"Version\":\"v0.1.13-0.20220812184215-3f9b119300de\",\"Sum\":\"h1:b68wxF4nfQjj1XTRHtjVjCximbhAwjztuzDEFGU+n9o=\",\"Replace\":null},{\"Path\":\"golang.org/x/vuln\",\"Version\":\"v0.0.0-20220725105440-4151a5aca1df\",\"Sum\":\"h1:BkeW9/QJhcigekDUPS9N9bIb0v7gPKKmLYeczVAqr2s=\",\"Replace\":null},{\"Path\":\"honnef.co/go/tools\",\"Version\":\"v0.3.2\",\"Sum\":\"h1:ytYb4rOqyp1TSa2EPvNVwtPQJctSELKaMyLfqNP4+34=\",\"Replace\":null},{\"Path\":\"mvdan.cc/gofumpt\",\"Version\":\"v0.3.1\",\"Sum\":\"h1:avhhrOmv0IuvQVK7fvwV91oFSGAk5/6Po8GXTzICeu8=\",\"Replace\":null},{\"Path\":\"mvdan.cc/xurls/v2\",\"Version\":\"v2.4.0\",\"Sum\":\"h1:tzxjVAj+wSBmDcF6zBB7/myTy3gX9xvi8Tyr28AuQgc=\",\"Replace\":null}],\"Settings\":[{\"Key\":\"-compiler\",\"Value\":\"gc\"},{\"Key\":\"-trimpath\",\"Value\":\"true\"},{\"Key\":\"CGO_ENABLED\",\"Value\":\"1\"},{\"Key\":\"GOARCH\",\"Value\":\"amd64\"},{\"Key\":\"GOOS\",\"Value\":\"darwin\"},{\"Key\":\"GOAMD64\",\"Value\":\"v1\"}],\"Version\":\"v0.9.4\"}"
  }
}


[Trace - 11:39:44 AM] Sending notification 'initialized'.
Params: {}


[Trace - 11:39:44 AM] Sending notification 'textDocument/didOpen'.
Params: {
  "textDocument": {
    "uri": "file:///Users/ibizaman/go/src/github.com/my/repo/myfile.go",
    "languageId": "golangci-lint",
    "version": 4,
    "text": "...\n"
  }
}


[Trace - 11:39:44 AM] Sending request 'textDocument/codeLens - (124)'.
Params: {
  "textDocument": {
    "uri": "file:///Users/ibizaman/go/src/github.com/my/repo/myfile.go"
  }
}


[Trace - 11:39:44 AM] Sending request 'textDocument/documentLink - (125)'.
Params: {
  "textDocument": {
    "uri": "file:///Users/ibizaman/go/src/github.com/my/repo/myfile.go"
  }
}


[Trace - 11:39:44 AM] Sending request 'textDocument/documentSymbol - (126)'.
Params: {
  "textDocument": {
    "uri": "file:///Users/ibizaman/go/src/github.com/my/repo/myfile.go"
  }
}


[Trace - 11:39:44 AM] Sending request 'textDocument/codeAction - (127)'.
Params: {
  "textDocument": {
    "uri": "file:///Users/ibizaman/go/src/github.com/my/repo/myfile.go"
  },
  "range": {
    "start": {
      "line": 25,
      "character": 0
    },
    "end": {
      "line": 25,
      "character": 0
    }
  },
  "context": {
    "diagnostics": []
  }
}


[Trace - 11:39:44 AM] Sending notification '$/cancelRequest'.
Params: {
  "id": 124
}


[Trace - 11:39:44 AM] Sending request 'textDocument/codeLens - (128)'.
Params: {
  "textDocument": {
    "uri": "file:///Users/ibizaman/go/src/github.com/my/repo/myfile.go"
  }
}


[Trace - 11:39:44 AM] Received request 'window/workDoneProgress/create - (1).
Params: {
  "token": "2015796113853353331"
}


[Trace - 11:39:44 AM] Sending response 'window/workDoneProgress/create - (1)'. Processing request took 0ms
Params: {
  "jsonrpc": "2.0",
  "id": 1,
  "result": null
}


[Trace - 11:39:44 AM] Received response 'nil - (124)' in 0ms.
Result: {
  "code": 0,
  "message": "context canceled"
}


[Trace - 11:39:44 AM] Received notification '$/progress'.
Params: {
  "token": "2015796113853353331",
  "value": {
    "kind": "begin",
    "message": "Loading packages...",
    "title": "Setting up workspace"
  }
}


[Trace - 11:39:44 AM] Received request 'workspace/configuration - (2).
Params: {
  "items": [
    {
      "scopeUri": "file:///Users/ibizaman/go/src/github.com/my/repo",
      "section": "gopls"
    }
  ]
}


[Trace - 11:39:44 AM] Sending response 'workspace/configuration - (2)'. Processing request took 0ms
Params: {
  "jsonrpc": "2.0",
  "id": 2,
  "result": [
    {
      "usePlaceholders": true,
      "hoverKind": "SynopsisDocumentation",
      "buildFlags": [],
      "linkTarget": "pkg.go.dev",
      "codelenses": {
        "gc_details": false,
        "generate": true,
        "regenerate_cgo": true,
        "tidy": true,
        "upgrade_dependency": true,
        "test": true,
        "vendor": true
      },
      "linksInHover": true,
      "gofumpt": false,
      "local": [
        "github.com/signalsciences"
      ],
      "directoryFilters": [],
      "importShortcut": "Both",
      "symbolMatcher": "Fuzzy",
      "symbolStyle": "Dynamic"
    }
  ]
}


[Trace - 11:39:44 AM] Sending notification '$/cancelRequest'.
Params: {
  "id": 127
}


[Trace - 11:39:44 AM] Sending notification '$/cancelRequest'.
Params: {
  "id": 125
}


[Trace - 11:39:44 AM] Received response 'nil - (125)' in 0ms.
Result: {
  "code": 0,
  "message": "context canceled"
}


[Trace - 11:39:49 AM] Sending request 'textDocument/documentLink - (129)'.
Params: {
  "textDocument": {
    "uri": "file:///Users/ibizaman/go/src/github.com/my/repo/myfile.go"
  }
}


[Trace - 11:39:49 AM] Sending notification '$/cancelRequest'.
Params: {
  "id": 126
}


[Trace - 11:39:49 AM] Sending request 'textDocument/documentSymbol - (130)'.
Params: {
  "textDocument": {
    "uri": "file:///Users/ibizaman/go/src/github.com/my/repo/myfile.go"
  }
}


[Trace - 11:39:49 AM] Sending request 'textDocument/codeAction - (131)'.
Params: {
  "textDocument": {
    "uri": "file:///Users/ibizaman/go/src/github.com/my/repo/myfile.go"
  },
  "range": {
    "start": {
      "line": 25,
      "character": 0
    },
    "end": {
      "line": 25,
      "character": 0
    }
  },
  "context": {
    "diagnostics": []
  }
}


[Trace - 11:39:49 AM] Received response 'nil - (126)' in 0ms.
Result: {
  "code": 0,
  "message": "context canceled"
}


[Trace - 11:39:49 AM] Received response 'nil - (127)' in 0ms.
Result: {
  "code": -32800,
  "message": "JSON RPC cancelled"
}


[Trace - 11:39:51 AM] Sending notification '$/cancelRequest'.
Params: {
  "id": 131
}


[Trace - 11:39:51 AM] Sending notification '$/cancelRequest'.
Params: {
  "id": 129
}


### Anything else?

I'm on the latest commit from master lsp branch: 7153b3d8648e8bad780df2dc2801170f943c5c9d
gopls version installed from brew is: 0.9.4

Everything works fine with the latest commit from [lsp-haskell](https://github.com/emacs-lsp/lsp-haskell/commit/485c1148ce4d27030bb95b21c7289809294e7d31)

Thank you for this wonderful tool 🙏 

pierre-fastly avatar Sep 02 '22 18:09 pierre-fastly

Also tried to downgrade gopls 0.8.3 but that didn't help 🤔 FTR I followed https://stackoverflow.com/a/65946969 which I'm copy-pasting here and adapting for gopls:

  1. Find the .rb file at Formulas, open it and then click "History"; for gopls, this is at https://github.com/Homebrew/homebrew-core/commits/master/Formula/gopls.rb
  2. Pick the desired version among the revisions, click three dots in the top right corner of the .rb file diff [...] and then click Raw and save the file on disk somewhere as gopls.rb.
  3. Unlink the current version with brew unlink gopls
  4. brew install ./gopls.rb

pierre-fastly avatar Sep 06 '22 16:09 pierre-fastly

Found the issue! I noticed that my setup was working fine on other go projects. So I diffed the lsp logs and found the following difference. In the project I had the issue, I had:

[Trace - 11:31:52 AM] Sending response 'workspace/configuration - (2)'. Processing request took 0ms
Params: {
  "jsonrpc": "2.0",
  "id": 2,
  "result": [
    {
      ...
      "local": [
        "github.com/my/project"
      ],
      ...
    }
  ]
}

While there wasn't the local field in the project that was working!

Actually, I was setting this from a .dir-locals.el file that was using an incorrect syntax. I needed to change from

 ((go-mode
-  . ((lsp-go-goimports-local "github.com/my/project")))
+  . ((lsp-go-goimports-local . "github.com/my/project")))

Now, lsp was working and the trace showed the local field needed to be a string, not a list:

      "local": "github.com/my/project",

pierre-fastly avatar Sep 21 '22 18:09 pierre-fastly