Skip to content

Failed to initialize lsp server in vscode #2068

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

Closed
berberman opened this issue Aug 3, 2021 · 9 comments · Fixed by haskell/vscode-haskell#424
Closed

Failed to initialize lsp server in vscode #2068

berberman opened this issue Aug 3, 2021 · 9 comments · Fixed by haskell/vscode-haskell#424
Labels
component: lsp status: needs info Not actionable, because there's missing information type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..

Comments

@berberman
Copy link
Collaborator

Your environment

HLS master, lsp 1.2.0.1

Which OS do you use:

NixOS

Which lsp-client do you use:

vscode 1.58.2

Describe your project (alternative: link to the project):

HLS

Actual behaviour

The server failed immediately because the field InitializeParams.capabilities.textDocument.semanticTokens.requests in initialize message was missing.

ghcide version: 1.4.1.0 (GHC: 8.10) (PATH: /home/berberman/.cabal/store/ghc-8.10.4/ghcide-1.4.1.0-e-ghcide-1f4fb458a9e7a7dd7b14385ee9c32f5bd3b0d484100205ce3cbeb2ffd99c7ebb/bin/ghcide)
 Starting LSP server...
If you are seeing this in a terminal, you probably should have run WITHOUT the --lsp option!
Got error while decoding initialize:
Error in $.params.capabilities.textDocument.semanticTokens: When parsing the record SemanticTokensClientCapabilities of type Language.LSP.Types.SemanticTokens.SemanticTokensClientCapabilities the key requests was not present.
 exiting 1 ...

Include debug information

The initialize request sent from my vscode client:

{
   "jsonrpc":"2.0",
   "id":0,
   "method":"initialize",
   "params":{
      "processId":111250,
      "clientInfo":{
         "name":"vscode",
         "version":"1.58.2"
      },
      "rootPath":"/home/berberman/Desktop/haskell/haskell-language-server",
      "rootUri":"file:///home/berberman/Desktop/haskell/haskell-language-server",
      "capabilities":{
         "workspace":{
            "applyEdit":true,
            "workspaceEdit":{
               "documentChanges":true,
               "resourceOperations":[
                  "create",
                  "rename",
                  "delete"
               ],
               "failureHandling":"textOnlyTransactional"
            },
            "didChangeConfiguration":{
               "dynamicRegistration":true
            },
            "didChangeWatchedFiles":{
               "dynamicRegistration":true
            },
            "symbol":{
               "dynamicRegistration":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
                  ]
               }
            },
            "executeCommand":{
               "dynamicRegistration":true
            },
            "configuration":true,
            "workspaceFolders":true
         },
         "textDocument":{
            "publishDiagnostics":{
               "relatedInformation":true,
               "versionSupport":false,
               "tagSupport":{
                  "valueSet":[
                     1,
                     2
                  ]
               }
            },
            "synchronization":{
               "dynamicRegistration":true,
               "willSave":true,
               "willSaveWaitUntil":true,
               "didSave":true
            },
            "completion":{
               "dynamicRegistration":true,
               "contextSupport":true,
               "completionItem":{
                  "snippetSupport":true,
                  "commitCharactersSupport":true,
                  "documentationFormat":[
                     "markdown",
                     "plaintext"
                  ],
                  "deprecatedSupport":true,
                  "preselectSupport":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
                  ]
               }
            },
            "hover":{
               "dynamicRegistration":true,
               "contentFormat":[
                  "markdown",
                  "plaintext"
               ]
            },
            "signatureHelp":{
               "dynamicRegistration":true,
               "signatureInformation":{
                  "documentationFormat":[
                     "markdown",
                     "plaintext"
                  ],
                  "parameterInformation":{
                     "labelOffsetSupport":true
                  }
               },
               "contextSupport":true
            },
            "definition":{
               "dynamicRegistration":true,
               "linkSupport":true
            },
            "references":{
               "dynamicRegistration":true
            },
            "documentHighlight":{
               "dynamicRegistration":true
            },
            "documentSymbol":{
               "dynamicRegistration":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
                  ]
               },
               "hierarchicalDocumentSymbolSupport":true
            },
            "codeAction":{
               "dynamicRegistration":true,
               "isPreferredSupport":true,
               "codeActionLiteralSupport":{
                  "codeActionKind":{
                     "valueSet":[
                        "",
                        "quickfix",
                        "refactor",
                        "refactor.extract",
                        "refactor.inline",
                        "refactor.rewrite",
                        "source",
                        "source.organizeImports"
                     ]
                  }
               }
            },
            "codeLens":{
               "dynamicRegistration":true
            },
            "formatting":{
               "dynamicRegistration":true
            },
            "rangeFormatting":{
               "dynamicRegistration":true
            },
            "onTypeFormatting":{
               "dynamicRegistration":true
            },
            "rename":{
               "dynamicRegistration":true,
               "prepareSupport":true
            },
            "documentLink":{
               "dynamicRegistration":true,
               "tooltipSupport":true
            },
            "typeDefinition":{
               "dynamicRegistration":true,
               "linkSupport":true
            },
            "implementation":{
               "dynamicRegistration":true,
               "linkSupport":true
            },
            "colorProvider":{
               "dynamicRegistration":true
            },
            "foldingRange":{
               "dynamicRegistration":true,
               "rangeLimit":5000,
               "lineFoldingOnly":true
            },
            "declaration":{
               "dynamicRegistration":true,
               "linkSupport":true
            },
            "selectionRange":{
               "dynamicRegistration":true
            },
            "callHierarchy":{
               "dynamicRegistration":true
            },
            "semanticTokens":{
               "dynamicRegistration":true,
               "tokenTypes":[
                  "comment",
                  "keyword",
                  "number",
                  "regexp",
                  "operator",
                  "namespace",
                  "type",
                  "struct",
                  "class",
                  "interface",
                  "enum",
                  "typeParameter",
                  "function",
                  "member",
                  "macro",
                  "variable",
                  "parameter",
                  "property",
                  "label"
               ],
               "tokenModifiers":[
                  "declaration",
                  "documentation",
                  "static",
                  "abstract",
                  "deprecated",
                  "async",
                  "readonly"
               ]
            }
         },
         "window":{
            "workDoneProgress":true
         }
      },
      "trace":"off",
      "workspaceFolders":[
         {
            "uri":"file:///home/berberman/Desktop/haskell/haskell-language-server",
            "name":"haskell-language-server"
         }
      ]
   }
}

According to the lsp specification (https://microsoft.github.io/language-server-protocol/specifications/specification-3-17/#semanticTokensClientCapabilities), this field is not optional, but it's clear that vscode didn't send this.

@berberman berberman added type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc.. status: needs attention component: lsp labels Aug 3, 2021
@July541
Copy link
Collaborator

July541 commented Aug 3, 2021

VSCode ignores data field in CallHierarchy too, even data has a value. https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocument_prepareCallHierarchy

@isovector
Copy link
Collaborator

isovector commented Aug 4, 2021

According to the lsp specification, this field is not optional, but it's clear that vscode didn't send this.

Sorta makes you think that maybe the spec is an afterthought, doesn't it? :)

@pepeiborra
Copy link
Collaborator

One way or another, We'll have to fix the problem in the lsp package by making the parser less strict.

And make a Hackage upload before we can put HLS 1.3.0.0 in Hackage

@berberman
Copy link
Collaborator Author

I found a related issue: microsoft/vscode-languageserver-node#780, where they said vscode-languageclient-7.0.0 works.

So we don't need to revise lsp package. Instead, update the dependency vscode-languageclient and make a new release of our vscode extension.

@berberman
Copy link
Collaborator Author

Reopened as we need a release of the extension

@berberman berberman reopened this Aug 6, 2021
@jneira
Copy link
Member

jneira commented Aug 6, 2021

will do asap, I think I ve seen some strange values in the actual config and I would like to fix them

@jneira
Copy link
Member

jneira commented Aug 8, 2021

we just have released a new version of the vscode extension, could you give a try to confirm it fixes the issue?
//cc @Ailrun

@jneira jneira added the status: needs info Not actionable, because there's missing information label Aug 8, 2021
@isovector
Copy link
Collaborator

Fixed for me!

@jneira
Copy link
Member

jneira commented Aug 9, 2021

great, so I guess we can close this
thanks to @berberman

@jneira jneira closed this as completed Aug 9, 2021
@jneira jneira removed this from the 1.4.0 milestone Aug 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: lsp status: needs info Not actionable, because there's missing information type: bug Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants