helix: "Failed to parse WorkspaceConfiguration params" with pyright LSP server
Summary
When trying to open any .py file with Helix 22.03 and the pyright LSP server configured, Helix crashes out as soon as the file is opened with the following backtrace:
thread ‘main’ panicked at ‘Failed to parse WorkspaceConfiguration params: Error { code: InvalidParams, message: “Invalid params: invalid value: string "", expected relative URL without a base.”, data: None }’, helix-lsp/src/lib.rs:216:22
v0.6.0 worked fine, presumably this is because of PR #1684.
Reproduction Steps
I tried this:
hx -vvv models.py
I expected this to happen:
- The editor is opened, I can edit the file, and pyright LSP server works as expected with diagnostics, completion, etc.
Instead, this happened:
- The editor immediately crashes out with a backtrace.
Helix log
~/.cache/helix/helix.log
2022-03-31T10:04:28.414 helix_view::theme [WARN] Theme: invalid style attribute: modifier
2022-03-31T10:04:28.447 mio::poll [TRACE] registering event source with poller: token=Token(1), interests=READABLE | WRITABLE
2022-03-31T10:04:28.447 mio::poll [TRACE] registering event source with poller: token=Token(2), interests=READABLE | WRITABLE
2022-03-31T10:04:28.447 mio::poll [TRACE] registering event source with poller: token=Token(3), interests=READABLE | WRITABLE
2022-03-31T10:04:28.447 mio::poll [TRACE] registering event source with poller: token=Token(4), interests=READABLE | WRITABLE
2022-03-31T10:04:28.447 mio::poll [TRACE] registering event source with poller: token=Token(5), interests=READABLE | WRITABLE
2022-03-31T10:04:28.447 helix_lsp::client [INFO] Using custom LSP config: "{\n \"python\": {\n \"analysis\": {\n \"autoSearchPaths\": true,\n \"diagnosticMode\": \"workspace\",\n \"useLibraryCodeForTypes\": true\n }\n }\n}\n"
2022-03-31T10:04:28.447 mio::poll [TRACE] registering event source with poller: token=Token(0), interests=READABLE
2022-03-31T10:04:28.447 mio::poll [TRACE] registering event source with poller: token=Token(1), interests=READABLE
2022-03-31T10:04:28.447 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":{"snippetSupport":false},"completionItemKind":{}},"hover":{"contentFormat":["markdown"]},"rename":{"dynamicRegistration":false,"honorsChangeAnnotations":false,"prepareSupport":false}},"window":{"workDoneProgress":true},"workspace":{"configuration":true,"didChangeConfiguration":{"dynamicRegistration":false}}},"initializationOptions":"{\n \"python\": {\n \"analysis\": {\n \"autoSearchPaths\": true,\n \"diagnosticMode\": \"workspace\",\n \"useLibraryCodeForTypes\": true\n }\n }\n}\n","processId":33075,"rootUri":"file:///home/me/work/code/project"},"id":0}
2022-03-31T10:04:28.668 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"Pyright language server 1.1.234 starting"}}
2022-03-31T10:04:28.668 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"Server root directory: /usr/lib/node_modules/pyright/dist/"}}
2022-03-31T10:04:28.669 helix_term::application [INFO] window/logMessage: LogMessageParams { typ: Info, message: "Pyright language server 1.1.234 starting" }
2022-03-31T10:04:28.670 helix_term::application [INFO] window/logMessage: LogMessageParams { typ: Info, message: "Server root directory: /usr/lib/node_modules/pyright/dist/" }
2022-03-31T10:04:28.672 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","id":0,"result":{"capabilities":{"textDocumentSync":2,"definitionProvider":{"workDoneProgress":true},"declarationProvider":{"workDoneProgress":true},"typeDefinitionProvider":{"workDoneProgress":true},"referencesProvider":{"workDoneProgress":true},"documentSymbolProvider":{"workDoneProgress":true},"workspaceSymbolProvider":{"workDoneProgress":true},"hoverProvider":{"workDoneProgress":true},"documentHighlightProvider":{"workDoneProgress":true},"renameProvider":{"prepareProvider":true,"workDoneProgress":true},"completionProvider":{"triggerCharacters":[".","["],"resolveProvider":true,"workDoneProgress":true},"signatureHelpProvider":{"triggerCharacters":["(",",",")"],"workDoneProgress":true},"codeActionProvider":{"codeActionKinds":["quickfix","source.organizeImports"],"workDoneProgress":true},"executeCommandProvider":{"commands":[],"workDoneProgress":true},"callHierarchyProvider":true}}}
2022-03-31T10:04:28.672 helix_lsp::transport [INFO] <- {"capabilities":{"callHierarchyProvider":true,"codeActionProvider":{"codeActionKinds":["quickfix","source.organizeImports"],"workDoneProgress":true},"completionProvider":{"resolveProvider":true,"triggerCharacters":[".","["],"workDoneProgress":true},"declarationProvider":{"workDoneProgress":true},"definitionProvider":{"workDoneProgress":true},"documentHighlightProvider":{"workDoneProgress":true},"documentSymbolProvider":{"workDoneProgress":true},"executeCommandProvider":{"commands":[],"workDoneProgress":true},"hoverProvider":{"workDoneProgress":true},"referencesProvider":{"workDoneProgress":true},"renameProvider":{"prepareProvider":true,"workDoneProgress":true},"signatureHelpProvider":{"triggerCharacters":["(",",",")"],"workDoneProgress":true},"textDocumentSync":2,"typeDefinitionProvider":{"workDoneProgress":true},"workspaceSymbolProvider":{"workDoneProgress":true}}}
2022-03-31T10:04:28.672 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","method":"initialized","params":{}}
2022-03-31T10:04:28.672 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","method":"workspace/didChangeConfiguration","params":{"settings":"{\n \"python\": {\n \"analysis\": {\n \"autoSearchPaths\": true,\n \"diagnosticMode\": \"workspace\",\n \"useLibraryCodeForTypes\": true\n }\n }\n}\n"}}
2022-03-31T10:04:28.672 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"languageId":"python","text":"","uri":"file:///home/me/work/code/project/project/causes/models.py","version":0}}}
2022-03-31T10:04:28.679 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","id":0,"method":"workspace/configuration","params":{"items":[{"scopeUri":"","section":"python"}]}}
2022-03-31T10:04:28.680 mio::poll [TRACE] deregistering event source from poller
2022-03-31T10:04:28.681 mio::poll [TRACE] deregistering event source from poller
2022-03-31T10:04:28.681 mio::poll [TRACE] deregistering event source from poller
2022-03-31T10:04:28.681 mio::poll [TRACE] deregistering event source from poller
2022-03-31T10:04:28.681 mio::poll [TRACE] deregistering event source from poller
config.toml:
[[language]]
name = "python"
language-server = { command = "pyright-langserver", args = ["--stdio"] }
auto-format = false
config = """
{
"python": {
"analysis": {
"autoSearchPaths": true,
"diagnosticMode": "workspace",
"useLibraryCodeForTypes": true
}
}
}
"""
Platform
Linux arch
Terminal Emulator
foot 1.11.0
Helix Version
helix 22.03 (d4e45fd4)
About this issue
- Original URL
- State: open
- Created 2 years ago
- Reactions: 3
- Comments: 29 (20 by maintainers)
Commits related to this issue
- fix: Some LSPs still want rootPath, so provide it Refs #1898 — committed to helix-editor/helix by archseer 2 years ago
- lsp: Implement support for workspace_folders (currently just one) Refs #1898 — committed to helix-editor/helix by archseer 2 years ago
this is my config for pyright , it’s work for me.
I don’t kown why that just have
config = {}or config have any value , pyright can be run.I’m using the latest main branch (helix 23.05 (57e538d0)). Pyright settings in
languages.tomldon’t work. It does work usingpyproject.tomlandpyrightconfig.json.If I create a directory
foocontainingrun.py(below), and call eitherhx fooorhx foo/run.py, I am able to control pyright configs from afoo/pyrightconfig.json. I can also do this withpyproject.toml. Ifpyrightconfig.jsonexists, no settings inpyproject.tomltake effect. Edit: This behavior is all the pyright server, I can tell that from the logs.I am not able to control the settings from
languages.tomlat all. Edit: The logs tell me that the settings are being sent, at least. Log at the end of this post.Here’s a dummy
run.pyfile to test if the configs take effectHere’s the
languages.tomlI’ve tried.This is the pyproject.toml I’ve tried:
and the
pyrightconfig.json:I’d appreciate anyone else’s input on this!
typeCheckingMode: "off"is being sent: 2023-07-06T15:31:16.987 helix_lsp::transport [INFO] pyright -> {"jsonrpc":"2.0","method":"workspace/didChangeConfiguration","params":{"settings":{"typeCheckingMode":"off"}}}(I triggered the verbose logging withhx --vvv run.py, then opened the log with:log-open, then turned on soft wrap with:set soft-wrap.enable true)Just tried it, it doesn’t work. I tried copy-pasting different configs I found on the internet, nothing works
Is it even possible to configure pyright? In my languages.toml I have:
I just want to turn off type checking. But it doesn’t do anything. No matter what I put in
configproperty is doesn’t do anything, and without it it doesn’t work.@schneiderfelipe, the following config makes pyright type check in strict mode:
Figured it out from looking at some vim setups: You have to specify the full
pyright.config.python.analysispath in the config: 😅Concur with above, on Helix 22.12
pyright-langserveris nonfunctional even with the emptyconfigsection. Have tried a bunch of configs with no success.Using @the-mikedavis’s config (
pyright==1.1.293):Related: https://github.com/microsoft/pyright/discussions/4602
@HarshilPatel007
I have the same crash. I think I managed to work around it with the following config. Basically setting the current directory “.” as one of the roots. I’m not sure how this behaves, but I’m hoping it falls back to using the current directory as the root if it can’t find any of the other files listed. This is useful for when creating one-off scripts and the like.
Note there is also the chance that I’ve made it so that it always uses the current directory, I don’t really understand the priority of the values listed after roots.
Yeah, we mention it in the installation docs.
https://aur.archlinux.org/packages/helix-git