helix
helix copied to clipboard
Trouble adding astro language server
I want to add the astro language server to languages.toml (https://github.com/withastro/language-tools/tree/main/packages/language-server). It is installed globally and callable as astro-ls
. My languages.toml entry looks like this:
[[language]]
name = "astro"
scope = "source.astro"
injection-regex = "astro"
file-types = ["astro"]
roots = ["package.json", "astro.config.mjs"]
language-server = { command = "astro-ls", args = ["--stdio"] }
indent = { tab-width = 2, unit = " " }
I have tried different roots such as ["astro.config.mjs"]
and []
, but the response is always, that there is no lsp loaded for this buffer.
There is no tree-sitter grammar for astro.
Does the log say anything when editing .astro
files? You may need to run in verbose mode with hx -v file.astro
.
2022-08-13T16:46:23.539 helix_lsp::transport [INFO] ->
{
"jsonrpc": "2.0",
"method": "initialize",
"params": {
"capabilities": {
"textDocument": {
"codeAction": {
"codeActionLiteralSupport": {
"codeActionKind": {
"valueSet": [
"",
"quickfix",
"refactor",
"refactor.extract",
"refactor.inline",
"refactor.rewrite",
"source",
"source.organizeImports"
]
}
}
},
"completion": {
"completionItem": {
"resolveSupport": {
"properties": [
"documentation",
"detail",
"additionalTextEdits"
]
},
"snippetSupport": false
},
"completionItemKind": {}
},
"hover": {
"contentFormat": [
"markdown"
]
},
"publishDiagnostics": {},
"rename": {
"dynamicRegistration": false,
"honorsChangeAnnotations": false,
"prepareSupport": false
},
"signatureHelp": {
"signatureInformation": {
"activeParameterSupport": true,
"documentationFormat": [
"markdown"
],
"parameterInformation": {
"labelOffsetSupport": true
}
}
}
},
"window": {
"workDoneProgress": true
},
"workspace": {
"applyEdit": true,
"configuration": true,
"didChangeConfiguration": {
"dynamicRegistration": false
},
"workspaceFolders": true
}
},
"processId": 30555,
"rootPath": "/d/dev/revealjs/astro_present",
"rootUri": "file:///d/dev/revealjs/astro_present",
"workspaceFolders": [
{
"name": "astro_present",
"uri": "file:///d/dev/revealjs/astro_present"
}
]
},
"id": 0
}
2022-08-13T16:46:23.959 helix_lsp::transport [INFO] <-
{
"jsonrpc": "2.0",
"id": 0,
"error": {
"code": -32603,
"message": "Request initialize failed with message: Cannot read properties of undefined (reading 'environment')"
}
}
2022-08-13T16:46:23.959 helix_lsp::transport [ERROR] <- InternalError: Request initialize failed with message: Cannot read properties of undefined (reading 'environment') 2022-08-13T16:46:23.959 helix_lsp [ERROR] failed to initialize language server: protocol error: InternalError: Request initialize failed with message: Cannot read properties of undefined (reading 'environment')
(I formatted the json)
Seems like their language server fails to initialize. But thank you for pointing out that there is a log, I didn't knew that.
As far as I know, "environment" isn't part of the LSP spec so this looks like something internal to Astro's LSP when it handles the initialize
request. Maybe it's expecting some info to be sent that we aren't currently sending?
Astro-ls did indeed expected an additional setting called environment
(type is "node" | "browser"
). A PR (https://github.com/withastro/language-tools/pull/373) was already made to default its value to "node"
if it is missing.
Ah awesome, looks like that PR is already merged. Besides that, it may be possible to supply the values they're looking for with the config
key in languages.toml
For example the json language server needs an initialization value to enable formatting: https://github.com/helix-editor/helix/blob/2968756baf6208d48902607c8f8cb3c00c279149/languages.toml#L123-L132
Yep, issue is fixed on our side (PR has been merged and released).
Don't hesitate to let me know if there's anything else we can do to better support Helix!
I hope this is the right place to ask this. It seems to be related to this issue.
I'm currently trying to setup astro-ls @astrojs/[email protected] on helix 22.12 (96ff64a8)
Unfortunately, the LSP is not working.
~/.cache/helix/helix.log after opening a .astro file
2022-12-14T22:25:14.795 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","method":"initialize","params":{"capabilities":{"textDocument":{"codeAction":{"codeActionLiteralSupport":{"codeActionKind":{"valueSet":["","quickfix","refactor","refactor.extract","refactor.inline","refactor.rewrite","source","source.organizeImports"]}}},"completion":{"completionItem":{"insertReplaceSupport":true,"resolveSupport":{"properties":["documentation","detail","additionalTextEdits"]},"snippetSupport":false},"completionItemKind":{}},"hover":{"contentFormat":["markdown"]},"publishDiagnostics":{},"rename":{"dynamicRegistration":false,"honorsChangeAnnotations":false,"prepareSupport":false},"signatureHelp":{"signatureInformation":{"activeParameterSupport":true,"documentationFormat":["markdown"],"parameterInformation":{"labelOffsetSupport":true}}}},"window":{"workDoneProgress":true},"workspace":{"applyEdit":true,"configuration":true,"didChangeConfiguration":{"dynamicRegistration":false},"executeCommand":{"dynamicRegistration":false},"symbol":{"dynamicRegistration":false},"workspaceFolders":true}},"processId":51499,"rootPath":"/Users/pedropeixoto/Projects/pedropeixoto.dev","rootUri":"file:///Users/pedropeixoto/Projects/pedropeixoto.dev","workspaceFolders":[{"name":"pedropeixoto.dev","uri":"file:///Users/pedropeixoto/Projects/pedropeixoto.dev"}]},"id":0}
2022-12-14T22:25:14.928 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"window/showMessage","params":{"message":"Astro: Couldn't load TypeScript from path undefined. Only HTML and CSS features will be enabled","type":2}}
2022-12-14T22:25:14.928 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","id":0,"result":{"capabilities":{"textDocumentSync":{"openClose":true,"change":2,"save":{"includeText":true}},"foldingRangeProvider":true,"definitionProvider":true,"typeDefinitionProvider":true,"referencesProvider":true,"implementationProvider":true,"renameProvider":true,"documentFormattingProvider":true,"codeActionProvider":{"codeActionKinds":["quickfix","source.organizeImports","source.sortImports"]},"completionProvider":{"resolveProvider":true,"triggerCharacters":[".","\"","'","`","/","@","<"," ",">","*","#","$","+","^","(","[","@","-",":"]},"colorProvider":true,"hoverProvider":true,"documentSymbolProvider":true,"linkedEditingRangeProvider":true,"semanticTokensProvider":{"legend":{"tokenModifiers":["declaration","static","async","readonly","defaultLibrary","local"],"tokenTypes":["class","enum","interface","namespace","typeParameter","type","parameter","variable","enumMember","property","function","method"]},"range":true,"full":true},"inlayHintProvider":true,"signatureHelpProvider":{"triggerCharacters":["(",",","<"],"retriggerCharacters":[")"]}}}}
2022-12-14T22:25:14.928 helix_lsp::transport [INFO] <- {"capabilities":{"codeActionProvider":{"codeActionKinds":["quickfix","source.organizeImports","source.sortImports"]},"colorProvider":true,"completionProvider":{"resolveProvider":true,"triggerCharacters":[".","\"","'","`","/","@","<"," ",">","*","#","$","+","^","(","[","@","-",":"]},"definitionProvider":true,"documentFormattingProvider":true,"documentSymbolProvider":true,"foldingRangeProvider":true,"hoverProvider":true,"implementationProvider":true,"inlayHintProvider":true,"linkedEditingRangeProvider":true,"referencesProvider":true,"renameProvider":true,"semanticTokensProvider":{"full":true,"legend":{"tokenModifiers":["declaration","static","async","readonly","defaultLibrary","local"],"tokenTypes":["class","enum","interface","namespace","typeParameter","type","parameter","variable","enumMember","property","function","method"]},"range":true},"signatureHelpProvider":{"retriggerCharacters":[")"],"triggerCharacters":["(",",","<"]},"textDocumentSync":{"change":2,"openClose":true,"save":{"includeText":true}},"typeDefinitionProvider":true}}
2022-12-14T22:25:14.928 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","method":"initialized","params":{}}
2022-12-14T22:25:14.928 helix_term::application [WARN] unhandled window/showMessage: ShowMessageParams { typ: Warning, message: "Astro: Couldn't load TypeScript from path undefined. Only HTML and CSS features will be enabled" }
2022-12-14T22:25:14.929 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"languageId":"astro","text":"---\nimport Layout from '../layouts/Layout.astro';\nconst a = b;\n---\n\n<Layout title=\"Welcome to Astro.\">\n <main>\n <h1>Welcome to Pedro Peixoto dev</h1>\n </main>\n</Layout>\n\n<style>\n main {\n margin: auto;\n padding: 1.5rem;\n max-width: 60ch;\n }\n h1 {\n font-size: 3rem;\n font-weight: 800;\n margin: 0;\n }\n</style>\n","uri":"file:///Users/pedropeixoto/Projects/pedropeixoto.dev/src/pages/index.astro","version":0}}}
2022-12-14T22:25:14.929 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"window/logMessage","params":{"type":4,"message":"Successfully initialized! 🚀"}}
2022-12-14T22:25:14.929 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","id":0,"method":"client/registerCapability","params":{"registrations":[{"id":"9f804a44-e933-4760-a123-81992f14cb00","method":"workspace/didChangeConfiguration","registerOptions":{}}]}}
2022-12-14T22:25:14.929 helix_term::application [INFO] window/logMessage: LogMessageParams { typ: Log, message: "Successfully initialized! 🚀" }
2022-12-14T22:25:14.929 helix_term::application [ERROR] Language Server: Method not found client/registerCapability
2022-12-14T22:25:15.943 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///Users/pedropeixoto/Projects/pedropeixoto.dev/src/pages/index.astro","diagnostics":[]}}
2022-12-14T22:25:16.531 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","method":"shutdown","params":null,"id":1}
2022-12-14T22:25:16.533 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","id":1,"result":null}
2022-12-14T22:25:16.533 helix_lsp::transport [INFO] <- null
2022-12-14T22:25:16.533 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","method":"exit","params":null}
The lines that caught my attention were:
2022-12-14T22:25:14.928 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"window/showMessage","params":{"message":"Astro: Couldn't load TypeScript from path undefined. Only HTML and CSS features will be enabled","type":2}}
...
2022-12-14T22:25:14.929 helix_term::application [ERROR] Language Server: Method not found client/registerCapability
My language.toml
[[language]]
name = "astro"
scope = "source.astro"
injection-regex = "astro"
file-types = ["astro"]
indent = { tab-width = 2, unit = " " }
roots = ["package.json", "astro.config.mjs"]
language-server = { command = "astro-ls", args = ["--stdio"] }
Am I trying to do something that is not supported, or just missing something on my configuration?
I hope this is the right place to ask this. It seems to be related to this issue.
I'm currently trying to setup astro-ls @astrojs/[email protected] on helix 22.12 (96ff64a8)
Unfortunately, the LSP is not working.
~/.cache/helix/helix.log after opening a .astro file
2022-12-14T22:25:14.795 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","method":"initialize","params":{"capabilities":{"textDocument":{"codeAction":{"codeActionLiteralSupport":{"codeActionKind":{"valueSet":["","quickfix","refactor","refactor.extract","refactor.inline","refactor.rewrite","source","source.organizeImports"]}}},"completion":{"completionItem":{"insertReplaceSupport":true,"resolveSupport":{"properties":["documentation","detail","additionalTextEdits"]},"snippetSupport":false},"completionItemKind":{}},"hover":{"contentFormat":["markdown"]},"publishDiagnostics":{},"rename":{"dynamicRegistration":false,"honorsChangeAnnotations":false,"prepareSupport":false},"signatureHelp":{"signatureInformation":{"activeParameterSupport":true,"documentationFormat":["markdown"],"parameterInformation":{"labelOffsetSupport":true}}}},"window":{"workDoneProgress":true},"workspace":{"applyEdit":true,"configuration":true,"didChangeConfiguration":{"dynamicRegistration":false},"executeCommand":{"dynamicRegistration":false},"symbol":{"dynamicRegistration":false},"workspaceFolders":true}},"processId":51499,"rootPath":"/Users/pedropeixoto/Projects/pedropeixoto.dev","rootUri":"file:///Users/pedropeixoto/Projects/pedropeixoto.dev","workspaceFolders":[{"name":"pedropeixoto.dev","uri":"file:///Users/pedropeixoto/Projects/pedropeixoto.dev"}]},"id":0} 2022-12-14T22:25:14.928 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"window/showMessage","params":{"message":"Astro: Couldn't load TypeScript from path undefined. Only HTML and CSS features will be enabled","type":2}} 2022-12-14T22:25:14.928 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","id":0,"result":{"capabilities":{"textDocumentSync":{"openClose":true,"change":2,"save":{"includeText":true}},"foldingRangeProvider":true,"definitionProvider":true,"typeDefinitionProvider":true,"referencesProvider":true,"implementationProvider":true,"renameProvider":true,"documentFormattingProvider":true,"codeActionProvider":{"codeActionKinds":["quickfix","source.organizeImports","source.sortImports"]},"completionProvider":{"resolveProvider":true,"triggerCharacters":[".","\"","'","`","/","@","<"," ",">","*","#","$","+","^","(","[","@","-",":"]},"colorProvider":true,"hoverProvider":true,"documentSymbolProvider":true,"linkedEditingRangeProvider":true,"semanticTokensProvider":{"legend":{"tokenModifiers":["declaration","static","async","readonly","defaultLibrary","local"],"tokenTypes":["class","enum","interface","namespace","typeParameter","type","parameter","variable","enumMember","property","function","method"]},"range":true,"full":true},"inlayHintProvider":true,"signatureHelpProvider":{"triggerCharacters":["(",",","<"],"retriggerCharacters":[")"]}}}} 2022-12-14T22:25:14.928 helix_lsp::transport [INFO] <- {"capabilities":{"codeActionProvider":{"codeActionKinds":["quickfix","source.organizeImports","source.sortImports"]},"colorProvider":true,"completionProvider":{"resolveProvider":true,"triggerCharacters":[".","\"","'","`","/","@","<"," ",">","*","#","$","+","^","(","[","@","-",":"]},"definitionProvider":true,"documentFormattingProvider":true,"documentSymbolProvider":true,"foldingRangeProvider":true,"hoverProvider":true,"implementationProvider":true,"inlayHintProvider":true,"linkedEditingRangeProvider":true,"referencesProvider":true,"renameProvider":true,"semanticTokensProvider":{"full":true,"legend":{"tokenModifiers":["declaration","static","async","readonly","defaultLibrary","local"],"tokenTypes":["class","enum","interface","namespace","typeParameter","type","parameter","variable","enumMember","property","function","method"]},"range":true},"signatureHelpProvider":{"retriggerCharacters":[")"],"triggerCharacters":["(",",","<"]},"textDocumentSync":{"change":2,"openClose":true,"save":{"includeText":true}},"typeDefinitionProvider":true}} 2022-12-14T22:25:14.928 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","method":"initialized","params":{}} 2022-12-14T22:25:14.928 helix_term::application [WARN] unhandled window/showMessage: ShowMessageParams { typ: Warning, message: "Astro: Couldn't load TypeScript from path undefined. Only HTML and CSS features will be enabled" } 2022-12-14T22:25:14.929 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"languageId":"astro","text":"---\nimport Layout from '../layouts/Layout.astro';\nconst a = b;\n---\n\n<Layout title=\"Welcome to Astro.\">\n <main>\n <h1>Welcome to Pedro Peixoto dev</h1>\n </main>\n</Layout>\n\n<style>\n main {\n margin: auto;\n padding: 1.5rem;\n max-width: 60ch;\n }\n h1 {\n font-size: 3rem;\n font-weight: 800;\n margin: 0;\n }\n</style>\n","uri":"file:///Users/pedropeixoto/Projects/pedropeixoto.dev/src/pages/index.astro","version":0}}} 2022-12-14T22:25:14.929 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"window/logMessage","params":{"type":4,"message":"Successfully initialized! 🚀"}} 2022-12-14T22:25:14.929 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","id":0,"method":"client/registerCapability","params":{"registrations":[{"id":"9f804a44-e933-4760-a123-81992f14cb00","method":"workspace/didChangeConfiguration","registerOptions":{}}]}} 2022-12-14T22:25:14.929 helix_term::application [INFO] window/logMessage: LogMessageParams { typ: Log, message: "Successfully initialized! 🚀" } 2022-12-14T22:25:14.929 helix_term::application [ERROR] Language Server: Method not found client/registerCapability 2022-12-14T22:25:15.943 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///Users/pedropeixoto/Projects/pedropeixoto.dev/src/pages/index.astro","diagnostics":[]}} 2022-12-14T22:25:16.531 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","method":"shutdown","params":null,"id":1} 2022-12-14T22:25:16.533 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","id":1,"result":null} 2022-12-14T22:25:16.533 helix_lsp::transport [INFO] <- null 2022-12-14T22:25:16.533 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","method":"exit","params":null}
The lines that caught my attention were:
2022-12-14T22:25:14.928 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"window/showMessage","params":{"message":"Astro: Couldn't load TypeScript from path undefined. Only HTML and CSS features will be enabled","type":2}} ... 2022-12-14T22:25:14.929 helix_term::application [ERROR] Language Server: Method not found client/registerCapability
My language.toml
[[language]] name = "astro" scope = "source.astro" injection-regex = "astro" file-types = ["astro"] indent = { tab-width = 2, unit = " " } roots = ["package.json", "astro.config.mjs"] language-server = { command = "astro-ls", args = ["--stdio"] }
Am I trying to do something that is not supported, or just missing something on my configuration?
Hello, our language server requires a path to TypeScript's tsserverlibrary.js
to be passed.
You can see more details here: https://github.com/withastro/language-tools/blob/main/docs/language-server/initParams.md
If anyone got this to work, it would be great to summarize the findings in the wiki page. Thanks in advance!
This seems like the right place to report this: I am trying to configure astro-ls
and I have added the typescript.serverPath
. But this seems to make astro-ls
crash.
Going through logs, I found this:
2023-04-05T03:10:14.021 helix_vcs [ERROR] Error {
context: "failed to open git repo",
source: Discover(
NoGitRepository {
path: "/home/keogami/.config/helix",
},
),
}
2023-04-05T03:10:14.021 helix_vcs [ERROR] failed to open diff base for /home/keogami/.config/helix/languages.toml
2023-04-05T03:10:14.021 helix_vcs [ERROR] Error {
context: "failed to open git repo",
source: Discover(
NoGitRepository {
path: "/home/keogami/.config/helix",
},
),
}
2023-04-05T03:10:14.021 helix_vcs [ERROR] failed to obtain current head name for /home/keogami/.config/helix/languages.toml
2023-04-05T03:10:14.022 helix_view::editor [ERROR] Failed to initialize the LSP for `source.toml` { cannot find binary path }
2023-04-05T03:10:28.304 helix_term::application [WARN] Ignoring a client/registerCapability request because dynamic capability registration is not enabled. Please report this upstream to the language server
2023-04-05T03:10:28.382 helix_term::application [ERROR] Language Server: Received malformed method call workspace/configuration in request 1: protocol error: InvalidParams: Invalid params: invalid value: string "/home/keogami/code/web/keogami", expected relative URL without a base.
2023-04-05T03:10:28.394 helix_lsp::transport [ERROR] err <- "/home/keogami/.local/share/pnpm/global/5/.pnpm/[email protected]/node_modules/vscode-jsonrpc/lib/common/connection.js:565\n"
2023-04-05T03:10:28.394 helix_lsp::transport [ERROR] err <- " responsePromise.reject(new messages_1.ResponseError(error.code, error.message, error.data));\n"
2023-04-05T03:10:28.394 helix_lsp::transport [ERROR] err <- " ^\n"
2023-04-05T03:10:28.394 helix_lsp::transport [ERROR] err <- "\n"
2023-04-05T03:10:28.394 helix_lsp::transport [ERROR] err <- "ResponseError: Malformed method call: workspace/configuration\n"
2023-04-05T03:10:28.394 helix_lsp::transport [ERROR] err <- " at handleResponse (/home/keogami/.local/share/pnpm/global/5/.pnpm/[email protected]/node_modules/vscode-jsonrpc/lib/common/connection.js:565:48)\n"
2023-04-05T03:10:28.395 helix_lsp::transport [ERROR] err <- " at handleMessage (/home/keogami/.local/share/pnpm/global/5/.pnpm/[email protected]/node_modules/vscode-jsonrpc/lib/common/connection.js:345:13)\n"
2023-04-05T03:10:28.395 helix_lsp::transport [ERROR] err <- " at processMessageQueue (/home/keogami/.local/share/pnpm/global/5/.pnpm/[email protected]/node_modules/vscode-jsonrpc/lib/common/connection.js:362:17)\n"
2023-04-05T03:10:28.395 helix_lsp::transport [ERROR] err <- " at Immediate.<anonymous> (/home/keogami/.local/share/pnpm/global/5/.pnpm/[email protected]/node_modules/vscode-jsonrpc/lib/common/connection.js:334:13)\n"
2023-04-05T03:10:28.395 helix_lsp::transport [ERROR] err <- " at process.processImmediate (node:internal/timers:478:21) {\n"
2023-04-05T03:10:28.395 helix_lsp::transport [ERROR] err <- " code: -32700,\n"
2023-04-05T03:10:28.395 helix_lsp::transport [ERROR] err <- " data: undefined\n"
2023-04-05T03:10:28.395 helix_lsp::transport [ERROR] err <- "}\n"
2023-04-05T03:10:28.395 helix_lsp::transport [ERROR] err <- "\n"
2023-04-05T03:10:28.395 helix_lsp::transport [ERROR] err <- "Node.js v19.8.1\n"
2023-04-05T03:10:28.425 helix_lsp::transport [ERROR] err: <- StreamClosed
2023-04-05T03:10:28.709 helix_lsp::transport [ERROR] err: <- IO(Os { code: 32, kind: BrokenPipe, message: "Broken pipe" })
in particular, these lines seems to be quite relevant
2023-04-05T03:10:28.304 helix_term::application [WARN] Ignoring a client/registerCapability request because dynamic capability registration is not enabled. Please report this upstream to the language server
2023-04-05T03:10:28.382 helix_term::application [ERROR] Language Server: Received malformed method call workspace/configuration in request 1: protocol error: InvalidParams: Invalid params: invalid value: string "/home/keogami/code/web/keogami", expected relative URL without a base.
I wonder if this could be a bug in astro-ls
, but I wanna confirm that its not me messing this up
Works for me on windows, but on linux, astro-ls fails to start with this in the helix logs:
2023-04-04T22:19:40.721 helix_lsp::transport [ERROR] err: <- Parse(Error("data did not match any variant of untagged enum ServerMessage", line: 0, column: 0))
2023-04-04T22:20:00.202 helix_lsp [ERROR] failed to initialize language server: request 0 timed out
2023-04-04T22:20:17.372 helix_term::application [ERROR] Timed out waiting for language servers to shutdown
I stumbled upon the same error as @keogami and tried to look into it a bit. I'm not very familiar with the language server protocol, but it seems to me as if astro-ls
is responding with a path instead of a URI like file:///...
and this is causing the request to fail to parse.
After changing a line of code in astro-ls
to make it send a proper URI, the error is gone, but helix responds with a null value, which again crashes astro-ls
.
This is what i got after sending a proper url:
2023-04-13T21:21:45.589 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"window/logMessage","params":{"type":4,"message":"Successfully initialized! 🚀"}}
2023-04-13T21:21:45.589 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","id":0,"method":"client/registerCapability","params":{"registrations":[{"id":"e966319b-69cb-4626-ae31-416067d125c7","method":"workspace/didChangeConfiguration","registerOptions":{}}]}}
2023-04-13T21:21:45.589 helix_term::application [INFO] window/logMessage: LogMessageParams { typ: Log, message: "Successfully initialized! 🚀" }
2023-04-13T21:21:45.589 helix_term::application [WARN] Ignoring a client/registerCapability request because dynamic capability registration is not enabled. Please report this upstream to the language server
2023-04-13T21:21:45.589 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","result":null,"id":0}
2023-04-13T21:21:45.594 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","id":1,"method":"workspace/configuration","params":{"items":[{"scopeUri":"file:///Users/josh/Developer/Personal/application-documents","section":"astro.typescript"}]}}
2023-04-13T21:21:45.594 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","result":[null],"id":1}
2023-04-13T21:21:45.635 helix_lsp::transport [ERROR] err <- "node:internal/process/promises:288\n"
2023-04-13T21:21:45.635 helix_lsp::transport [ERROR] err <- " triggerUncaughtException(err, true /* fromPromise */);\n"
2023-04-13T21:21:45.635 helix_lsp::transport [ERROR] err <- " ^\n"
2023-04-13T21:21:45.635 helix_lsp::transport [ERROR] err <- "\n"
2023-04-13T21:21:45.635 helix_lsp::transport [ERROR] err <- "TypeError: Invalid host defined options\n"
2023-04-13T21:21:45.635 helix_lsp::transport [ERROR] err <- " at eval (eval at <anonymous> (/snapshot/language-tools/packages/language-server/dist/core/worker/TSXWorker.js:4:23), <anonymous>:3:1)\n"
2023-04-13T21:21:45.635 helix_lsp::transport [ERROR] err <- " at /snapshot/language-tools/packages/language-server/dist/core/worker/TSXWorker.js:6:36\n"
2023-04-13T21:21:45.635 helix_lsp::transport [ERROR] err <- " at /snapshot/language-tools/node_modules/.pnpm/[email protected]/node_modules/synckit/lib/index.cjs:271:39\n"
2023-04-13T21:21:45.635 helix_lsp::transport [ERROR] err <- " at Generator.next (<anonymous>)\n"
2023-04-13T21:21:45.635 helix_lsp::transport [ERROR] err <- " at /snapshot/language-tools/node_modules/.pnpm/[email protected]/node_modules/synckit/lib/index.cjs:34:61\n"
2023-04-13T21:21:45.635 helix_lsp::transport [ERROR] err <- " at new Promise (<anonymous>)\n"
2023-04-13T21:21:45.635 helix_lsp::transport [ERROR] err <- " at __async (/snapshot/language-tools/node_modules/.pnpm/[email protected]/node_modules/synckit/lib/index.cjs:18:10)\n"
2023-04-13T21:21:45.635 helix_lsp::transport [ERROR] err <- " at /snapshot/language-tools/node_modules/.pnpm/[email protected]/node_modules/synckit/lib/index.cjs:267:16\n"
2023-04-13T21:21:45.635 helix_lsp::transport [ERROR] err <- " at MessagePort.<anonymous> (/snapshot/language-tools/node_modules/.pnpm/[email protected]/node_modules/synckit/lib/index.cjs:278:12)\n"
2023-04-13T21:21:45.635 helix_lsp::transport [ERROR] err <- " at [nodejs.internal.kHybridDispatch] (node:internal/event_target:645:20)\n"
2023-04-13T21:21:45.635 helix_lsp::transport [ERROR] err <- "\n"
Has anyone gotten this to work?
Filed this just now: https://github.com/withastro/language-tools/issues/526
CC @eulervoid
Let's get this working!
After changing a line of code in
astro-ls
to make it send a proper URI, the error is gone, but helix responds with a null value, which again crashesastro-ls
.
@eulervoid as I understand, this request is to get the value of the "typescript" config item that you should pass to the LSP. Did you add this to your languages.toml
for the astro language?
config = { "typescript" = { serverPath = "/full/path/to/your/node_modules/typescript/lib/tsserverlibrary.js" }, "environment" = "node" }
I think everything works after the path/uri inconsistency is fixed (see https://github.com/withastro/language-tools/pull/527).
I'll make a change to the wiki once this has been merged/released upstream. Not sure what is the best way to install and provide the path to the tsserverlibrary.js
though. Any suggestion is welcome!
The problem was fixed in https://github.com/withastro/language-tools/releases/tag/%40astrojs%2Flanguage-server%401.0.5
Here is my ~/.config/helix/languages.toml
:
[[language]]
name = "astro"
scope = "source.astro"
injection-regex = "astro"
file-types = ["astro"]
roots = ["package.json", "astro.config.mjs"]
language-server = { command = "astro-ls", args = ["--stdio"] }
auto-format = true
Here is my .helix/languages.toml
inside my workspace folder:
[[language]]
name = "astro"
config = { "typescript" = { serverPath = "/home/beeb/path_to_my_project/node_modules/typescript/lib/tsserverlibrary.js" }, "environment" = "node" }
I couldn't make it work with a relative path to tsserverlibrary.js
.
Wiki has been updated: https://github.com/helix-editor/helix/wiki/How-to-install-the-default-language-servers#astro
I've followed the wiki to a tee and it's still not working for me. Here's what the end of my logs look like after exiting Helix with a .astro file open
2023-07-25T19:21:03.819 helix_vcs [ERROR] failed to open diff base for /<path to project>/src/components/Navigation.astro
2023-07-25T19:21:04.104 helix_lsp::transport [ERROR] <- InternalError: Request initialize failed with message: Can't find typescript.js or tsserverlibrary.js in undefined
2023-07-25T19:21:04.104 helix_lsp [ERROR] failed to initialize language server: protocol error: InternalError: Request initialize failed with message: Can't find typescript.js or tsserverlibrary.js in undefined
2023-07-25T19:21:11.514 helix_term::application [ERROR] Timed out waiting for language servers to shutdown
I wish I knew what undefined
is meant to be...
@Teajey so you have defined the serverPath
config option with an absolute path to the tsserverlibrary.js
in your node_modules/typescript/lib
folder?
Yes, exactly.
Here's my config
[[language]]
name = "astro"
scope = "source.astro"
injection-regex = "astro"
file-types = ["astro"]
roots = ["package.json", "astro.config.mjs"]
language-server = { command = "astro-ls", args = ["--stdio"] }
And local project config
[[language]]
name = "astro"
config = { "typescript" = { serverPath = "/<path to project>/node_modules/typescript/lib/tsserverlibrary.js" }, "environment" = "node" }
Edit: Same result if I move the serverPath
into the global config
@Teajey and you did npm install typescript
in your project, right? i.e. the file exists ?
It does indeed. I made a sanity check. I think the issue lies in that it's searching for tsserverlibrary.js
in "undefined
"
Yeah something might have changed in their tooling, like the name of the options. Try to see if there is any info on the astro lsp repo. I haven't worked on an astro project in a little while and can't really test right now.
I think they migrated to using volar recently so maybe the option is not needed anymore.
Hello! In 2.0 of our language server we updated it to be Volar-based, so our options are now the same as the Vue LSP in regard to the server path. So for the TypeScript path, that would be typescript.tsdk
. You can see how that work for instance in the nvim-lspconfig for Astro: https://github.com/neovim/nvim-lspconfig/blob/6f426c34c8e21af2f934e56be9d1198a507ecc9f/lua/lspconfig/server_configurations/astro.lua#L18
I am converting this to a discussion since any concrete bugs upstream/in helix seem to be resolved