Skip to content
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

"Failed to parse WorkspaceConfiguration params" with pyright LSP server #1898

Open
subsonik opened this issue Mar 31, 2022 · 29 comments
Open
Labels
C-bug Category: This is a bug upstream

Comments

@subsonik
Copy link

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:

  1. 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 (d4e45fd)

@subsonik subsonik added the C-bug Category: This is a bug label Mar 31, 2022
@archseer
Copy link
Member

Seems to rely on pyright rootPath which was deprecated for rootUri. But that in turn was deprecated by workspaceFolders. Pyright checks workspaceFolders frist, then rootPath (but not Uri).

I guess we should specify all three, the LSP spec is getting ridiculous.

@archseer
Copy link
Member

Can you test 84e799f ?

@subsonik
Copy link
Author

When using my config from above:

2022-03-31T11:00:42.674 helix_view::theme [WARN] Theme: invalid style attribute: modifier
2022-03-31T11:00:42.680 helix_view::editor [ERROR] Failed to initialize the LSP for `source.toml` { LSP not defined }
2022-03-31T11:00:50.361 helix_view::theme [WARN] Theme: invalid style attribute: modifier
2022-03-31T11:00:50.378 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-31T11:00:50.378 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":37058,"rootPath":"/home/john.arch/work/code/altu","rootUri":"file:///home/john.arch/work/code/altu"},"id":0}
2022-03-31T11:00:50.610 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"Pyright language server 1.1.234 starting"}}
2022-03-31T11:00:50.610 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-31T11:00:50.610 helix_term::application [INFO] window/logMessage: LogMessageParams { typ: Info, message: "Pyright language server 1.1.234 starting" }
2022-03-31T11:00:50.610 helix_term::application [INFO] window/logMessage: LogMessageParams { typ: Info, message: "Server root directory: /usr/lib/node_modules/pyright/dist/" }
2022-03-31T11:00:50.617 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-31T11:00:50.617 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-31T11:00:50.617 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","method":"initialized","params":{}}
2022-03-31T11:00:50.617 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-31T11:00:50.617 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"languageId":"python","text":"\n","uri":"file:///home/john.arch/work/code/altu/altu/causes/test.py","version":0}}}
2022-03-31T11:00:50.619 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","id":0,"method":"workspace/configuration","params":{"items":[{"scopeUri":"","section":"python"}]}}

When commenting out the 'config' option in my languages.toml, I can load the document and there's no backtrace, but there's also no LSP functionality, completion, diagnostics, etc:

2022-03-31T11:03:15.408 helix_view::theme [WARN] Theme: invalid style attribute: modifier
2022-03-31T11:03:15.425 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}}},"processId":37120,"rootPath":"/home/john.arch/work/code/altu","rootUri":"file:///home/john.arch/work/code/altu"},"id":0}
2022-03-31T11:03:15.649 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"Pyright language server 1.1.234 starting"}}
2022-03-31T11:03:15.649 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-31T11:03:15.649 helix_term::application [INFO] window/logMessage: LogMessageParams { typ: Info, message: "Pyright language server 1.1.234 starting" }
2022-03-31T11:03:15.650 helix_term::application [INFO] window/logMessage: LogMessageParams { typ: Info, message: "Server root directory: /usr/lib/node_modules/pyright/dist/" }
2022-03-31T11:03:15.655 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-31T11:03:15.655 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-31T11:03:15.656 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","method":"initialized","params":{}}
2022-03-31T11:03:15.656 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"languageId":"python","text":"\n","uri":"file:///home/john.arch/work/code/altu/altu/causes/test.py","version":0}}}
2022-03-31T11:03:17.131 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","method":"textDocument/didChange","params":{"contentChanges":[{"range":{"end":{"character":0,"line":0},"start":{"character":0,"line":0}},"text":"i"}],"textDocument":{"uri":"file:///home/john.arch/work/code/altu/altu/causes/test.py","version":1}}}
2022-03-31T11:03:17.216 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","method":"textDocument/didChange","params":{"contentChanges":[{"range":{"end":{"character":1,"line":0},"start":{"character":1,"line":0}},"text":"m"}],"textDocument":{"uri":"file:///home/john.arch/work/code/altu/altu/causes/test.py","version":2}}}
2022-03-31T11:03:17.418 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","method":"textDocument/completion","params":{"position":{"character":2,"line":0},"textDocument":{"uri":"file:///home/john.arch/work/code/altu/altu/causes/test.py"}},"id":1}
2022-03-31T11:03:18.201 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","method":"textDocument/didChange","params":{"contentChanges":[{"range":{"end":{"character":2,"line":0},"start":{"character":2,"line":0}},"text":"p"}],"textDocument":{"uri":"file:///home/john.arch/work/code/altu/altu/causes/test.py","version":3}}}
2022-03-31T11:03:18.402 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","method":"textDocument/completion","params":{"position":{"character":3,"line":0},"textDocument":{"uri":"file:///home/john.arch/work/code/altu/altu/causes/test.py"}},"id":2}
2022-03-31T11:03:19.617 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","method":"textDocument/didChange","params":{"contentChanges":[{"range":{"end":{"character":3,"line":0},"start":{"character":3,"line":0}},"text":"o"}],"textDocument":{"uri":"file:///home/john.arch/work/code/altu/altu/causes/test.py","version":4}}}
2022-03-31T11:03:19.818 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","method":"textDocument/completion","params":{"position":{"character":4,"line":0},"textDocument":{"uri":"file:///home/john.arch/work/code/altu/altu/causes/test.py"}},"id":3}
2022-03-31T11:03:21.524 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","method":"textDocument/didChange","params":{"contentChanges":[{"range":{"end":{"character":4,"line":0},"start":{"character":4,"line":0}},"text":"r"}],"textDocument":{"uri":"file:///home/john.arch/work/code/altu/altu/causes/test.py","version":5}}}
2022-03-31T11:03:21.726 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","method":"textDocument/completion","params":{"position":{"character":5,"line":0},"textDocument":{"uri":"file:///home/john.arch/work/code/altu/altu/causes/test.py"}},"id":4}
2022-03-31T11:03:23.459 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","method":"shutdown","params":null,"id":5}
2022-03-31T11:03:23.460 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","id":5,"result":null}
2022-03-31T11:03:23.460 helix_lsp::transport [INFO] <- null
2022-03-31T11:03:23.461 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","method":"exit","params":null}

Running helix 22.05-dev (84e799f0)

Thanks for the quick reply! :)

@archseer
Copy link
Member

archseer commented Apr 1, 2022

Opened an upstream issue, I'm out of ideas

@the-mikedavis the-mikedavis added A-language-server Area: Language server client upstream and removed A-language-server Area: Language server client labels Apr 1, 2022
@archseer
Copy link
Member

archseer commented Apr 1, 2022

Can you try 8adf0c1 ?

@subsonik
Copy link
Author

subsonik commented Apr 1, 2022

It works, thank you so much!

If I specify the 'config' option in languages.toml, even if its just an empty string, everything works as expected. But, if I comment 'config' out, LSP functionality no longer works, and after 10 secs or so, I get the error:

Async job failed: request timed out

I can live with specifying an empty 'config' option to get it to work, but should I raise this as a separate issue?

@archseer
Copy link
Member

archseer commented Apr 1, 2022

Can you provide logs for both success and failure cases? I need more information to diagnose this.

@subsonik
Copy link
Author

subsonik commented Apr 1, 2022

Of course.

Here it works fine, with config = "":

2022-04-01T09:01:32.476 helix_view::theme [WARN] Theme: invalid style attribute: modifier
2022-04-01T09:01:32.493 helix_lsp::client [INFO] Using custom LSP config: ""
2022-04-01T09:01:32.493 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},"workspaceFolders":true}},"initializationOptions":"","processId":51730,"rootPath":"/home/john.arch","rootUri":"file:///home/john.arch","workspaceFolders":[{"name":"john.arch","uri":"file:///home/john.arch"}]},"id":0}
2022-04-01T09:01:32.714 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"Pyright language server 1.1.234 starting"}}
2022-04-01T09:01:32.714 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"Server root directory: /usr/lib/node_modules/pyright/dist/"}}
2022-04-01T09:01:32.715 helix_term::application [INFO] window/logMessage: LogMessageParams { typ: Info, message: "Pyright language server 1.1.234 starting" }
2022-04-01T09:01:32.715 helix_term::application [INFO] window/logMessage: LogMessageParams { typ: Info, message: "Server root directory: /usr/lib/node_modules/pyright/dist/" }
2022-04-01T09:01:32.722 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-04-01T09:01:32.722 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-04-01T09:01:32.722 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","method":"initialized","params":{}}
2022-04-01T09:01:32.723 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","method":"workspace/didChangeConfiguration","params":{"settings":""}}
2022-04-01T09:01:32.723 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"languageId":"python","text":"\n","uri":"file:///home/john.arch/test.py","version":0}}}
2022-04-01T09:01:32.724 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","id":0,"method":"client/registerCapability","params":{"registrations":[{"id":"14a88d15-1cf1-4de9-964a-269e5c4eaa30","method":"workspace/didChangeWorkspaceFolders","registerOptions":{}}]}}
2022-04-01T09:01:32.725 helix_lsp [WARN] unhandled lsp request: client/registerCapability
2022-04-01T09:01:32.725 helix_term::application [ERROR] Method not found client/registerCapability
2022-04-01T09:01:32.726 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","id":1,"method":"workspace/configuration","params":{"items":[{"scopeUri":"file:///home/john.arch","section":"python"}]}}
2022-04-01T09:01:32.726 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","result":[null],"id":1}
2022-04-01T09:01:32.727 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","id":2,"method":"workspace/configuration","params":{"items":[{"scopeUri":"file:///home/john.arch","section":"python.analysis"}]}}
2022-04-01T09:01:32.727 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","result":[null],"id":2}
2022-04-01T09:01:32.728 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","id":3,"method":"workspace/configuration","params":{"items":[{"scopeUri":"file:///home/john.arch","section":"pyright"}]}}
2022-04-01T09:01:32.728 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","result":[null],"id":3}
2022-04-01T09:01:33.720 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"No configuration file found."}}
2022-04-01T09:01:33.721 helix_term::application [INFO] window/logMessage: LogMessageParams { typ: Info, message: "No configuration file found." }
2022-04-01T09:01:33.721 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"No pyproject.toml file found."}}
2022-04-01T09:01:33.721 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"window/logMessage","params":{"type":2,"message":"stubPath /home/john.arch/typings is not a valid directory."}}
2022-04-01T09:01:33.721 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"Assuming Python platform Linux"}}
2022-04-01T09:01:33.721 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"window/logMessage","params":{"type":2,"message":"Exception received when installing file system watcher: TypeError [ERR_FEATURE_UNAVAILABLE_ON_PLATFORM]: The feature watch recursively is unavailable on the current platform, which is being used to run Node.js"}}
2022-04-01T09:01:33.721 helix_term::application [INFO] window/logMessage: LogMessageParams { typ: Info, message: "No pyproject.toml file found." }
2022-04-01T09:01:33.721 helix_term::application [INFO] window/logMessage: LogMessageParams { typ: Warning, message: "stubPath /home/john.arch/typings is not a valid directory." }
2022-04-01T09:01:33.721 helix_term::application [INFO] window/logMessage: LogMessageParams { typ: Info, message: "Assuming Python platform Linux" }
2022-04-01T09:01:33.721 helix_term::application [INFO] window/logMessage: LogMessageParams { typ: Warning, message: "Exception received when installing file system watcher: TypeError [ERR_FEATURE_UNAVAILABLE_ON_PLATFORM]: The feature watch recursively is unavailable on the current platform, which is being used to run Node.js" }
2022-04-01T09:01:33.721 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"window/logMessage","params":{"type":2,"message":"Exception received when installing file system watcher: TypeError [ERR_FEATURE_UNAVAILABLE_ON_PLATFORM]: The feature watch recursively is unavailable on the current platform, which is being used to run Node.js"}}
2022-04-01T09:01:33.721 helix_term::application [INFO] window/logMessage: LogMessageParams { typ: Warning, message: "Exception received when installing file system watcher: TypeError [ERR_FEATURE_UNAVAILABLE_ON_PLATFORM]: The feature watch recursively is unavailable on the current platform, which is being used to run Node.js" }
2022-04-01T09:01:33.722 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"window/logMessage","params":{"type":2,"message":"Exception received when installing file system watcher: TypeError [ERR_FEATURE_UNAVAILABLE_ON_PLATFORM]: The feature watch recursively is unavailable on the current platform, which is being used to run Node.js"}}
2022-04-01T09:01:33.722 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"Searching for source files"}}
2022-04-01T09:01:33.722 helix_term::application [INFO] window/logMessage: LogMessageParams { typ: Warning, message: "Exception received when installing file system watcher: TypeError [ERR_FEATURE_UNAVAILABLE_ON_PLATFORM]: The feature watch recursively is unavailable on the current platform, which is being used to run Node.js" }
2022-04-01T09:01:33.722 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"Found 1471 source files"}}
2022-04-01T09:01:33.722 helix_term::application [INFO] window/logMessage: LogMessageParams { typ: Info, message: "Searching for source files" }
2022-04-01T09:01:33.722 helix_term::application [INFO] window/logMessage: LogMessageParams { typ: Info, message: "Found 1471 source files" }
2022-04-01T09:01:33.962 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///home/john.arch/test.py","version":0,"diagnostics":[]}}

And here it fails with the config option unset. I open a new file and type 'im', attempting to trigger completion for the 'import' keyword:

2022-04-01T09:03:52.106 helix_view::theme [WARN] Theme: invalid style attribute: modifier
2022-04-01T09:03:52.122 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},"workspaceFolders":true}},"processId":51803,"rootPath":"/home/john.arch","rootUri":"file:///home/john.arch","workspaceFolders":[{"name":"john.arch","uri":"file:///home/john.arch"}]},"id":0}
2022-04-01T09:03:52.360 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"Pyright language server 1.1.234 starting"}}
2022-04-01T09:03:52.361 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"Server root directory: /usr/lib/node_modules/pyright/dist/"}}
2022-04-01T09:03:52.361 helix_term::application [INFO] window/logMessage: LogMessageParams { typ: Info, message: "Pyright language server 1.1.234 starting" }
2022-04-01T09:03:52.361 helix_term::application [INFO] window/logMessage: LogMessageParams { typ: Info, message: "Server root directory: /usr/lib/node_modules/pyright/dist/" }
2022-04-01T09:03:52.368 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-04-01T09:03:52.368 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-04-01T09:03:52.368 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","method":"initialized","params":{}}
2022-04-01T09:03:52.369 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"languageId":"python","text":"\n","uri":"file:///home/john.arch/test.py","version":0}}}
2022-04-01T09:03:52.371 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","id":0,"method":"client/registerCapability","params":{"registrations":[{"id":"ef8081e8-79eb-4ff1-806b-78dc00272954","method":"workspace/didChangeWorkspaceFolders","registerOptions":{}}]}}
2022-04-01T09:03:52.371 helix_lsp [WARN] unhandled lsp request: client/registerCapability
2022-04-01T09:03:52.371 helix_term::application [ERROR] Method not found client/registerCapability
2022-04-01T09:03:53.262 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","method":"textDocument/didChange","params":{"contentChanges":[{"range":{"end":{"character":0,"line":0},"start":{"character":0,"line":0}},"text":"i"}],"textDocument":{"uri":"file:///home/john.arch/test.py","version":1}}}
2022-04-01T09:03:53.344 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","method":"textDocument/didChange","params":{"contentChanges":[{"range":{"end":{"character":1,"line":0},"start":{"character":1,"line":0}},"text":"m"}],"textDocument":{"uri":"file:///home/john.arch/test.py","version":2}}}
2022-04-01T09:03:53.546 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","method":"textDocument/completion","params":{"position":{"character":2,"line":0},"textDocument":{"uri":"file:///home/john.arch/test.py"}},"id":1}

@archseer
Copy link
Member

archseer commented Apr 5, 2022

It seems like it won't really do much without autoSearchPaths specified.

@HarshilPatel007
Copy link

@archseer @subsonik , I've got same crash. what should I do now to fix it. did you able to fix? how did you fixed it?

@archseer
Copy link
Member

archseer commented May 2, 2022

It's fixed on the latest master, but not on 22.03

@HarshilPatel007
Copy link

HarshilPatel007 commented May 2, 2022

@archseer , is there any binary for arch linux to try something like, helix-git? I don't want to compile.

@archseer
Copy link
Member

archseer commented May 2, 2022

Yeah, we mention it in the installation docs.

https://aur.archlinux.org/packages/helix-git

@HarshilPatel007
Copy link

@archseer , thanks a lot. currently learning neovim and going through little crazy stuff. helix came to rescue. 😄

@HarshilPatel007
Copy link

HarshilPatel007 commented May 3, 2022

@archseer ,
tested the latest build from helix-git.

it works fine with existing python file.
but, when I've tried to create new python file that didn't exist, it crashed.

➜  test111 RUST_BACKTRACE=full hx test.py
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:248:22
stack backtrace:
   0:     0x55fc42fc23f2 - <unknown>
   1:     0x55fc428b731c - <unknown>
   2:     0x55fc42fbb135 - <unknown>
   3:     0x55fc42fc52fb - <unknown>
   4:     0x55fc42fc5026 - <unknown>
   5:     0x55fc42e826fb - <unknown>
   6:     0x55fc42fc5afe - <unknown>
   7:     0x55fc42fc57b4 - <unknown>
   8:     0x55fc42fc2904 - <unknown>
   9:     0x55fc42fc550d - <unknown>
  10:     0x55fc4283d123 - <unknown>
  11:     0x55fc4283d213 - <unknown>
  12:     0x55fc42ab2632 - <unknown>
  13:     0x55fc42e7ec2d - <unknown>
  14:     0x55fc42e904df - <unknown>
  15:     0x55fc42e3451d - <unknown>
  16:     0x55fc42e362f9 - <unknown>
  17:     0x55fc42e7584c - <unknown>
  18:     0x55fc42e32fda - <unknown>
  19:     0x55fc42e36163 - <unknown>
  20:     0x55fc42e66cbd - <unknown>
  21:     0x55fc42fc1af2 - <unknown>
  22:     0x55fc42e37a02 - <unknown>
  23:     0x7fb1db082310 - __libc_start_call_main
  24:     0x7fb1db0823c1 - __libc_start_main@GLIBC_2.2.5
  25:     0x55fc4286b7b5 - <unknown>
  26:                0x0 - <unknown>

@paul-scott
Copy link
Contributor

@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.

[[language]]
name = "python"
roots = ["pyproject.toml", "setup.py", "Poetry.lock", "."]
language-server = { command = "pyright-langserver", args = ["--stdio"] }
auto-format = false
config = {}

@erasin
Copy link
Contributor

erasin commented Jul 31, 2022

this is my config for pyright , it's work for me.

[[language]]
name = "python"
file-types = ["py", "pyi"]
roots = ["pyproject.toml","pyrightconfig.json"]
language-server = { command = "pyright-langserver", args = ["--stdio"] }
# config = { "analysis" = { "autoSearchPaths" = true, "diagnosticMode" = "workspace", "useLibraryCodeForTypes" = true } }
# or
config = {}

I don't kown why that just have config = {} or config have any value , pyright can be run.

@blt-r
Copy link
Contributor

blt-r commented Jan 12, 2023

Is it even possible to configure pyright?
In my languages.toml I have:

[[language]]
name = "python"
language-server = { command = "pyright-langserver", args = ["--stdio"] }
config = """
{
  "python": {
    "analisys": {
      "autoSearchPaths": true, 
      "diagnosticMode": "workspace",
      "useLibraryCodeForTypes": true,
      "typeCheckingMode": "off"
    }
  }
}
"""

I just want to turn off type checking. But it doesn't do anything. No matter what I put in config property is doesn't do anything, and without it it doesn't work.

@the-mikedavis
Copy link
Member

Did you try Erasin's configuration from the parent comment?

[[language]]
name = "python"
file-types = ["py", "pyi"]
roots = ["pyproject.toml","pyrightconfig.json"]
language-server = { command = "pyright-langserver", args = ["--stdio"] }
config = { "analysis" = { "autoSearchPaths" = true, "diagnosticMode" = "workspace", "useLibraryCodeForTypes" = true } }

config should be a TOML table rather than a string. I also see a typo in your config: "analisys"

@blt-r
Copy link
Contributor

blt-r commented Jan 12, 2023

Just tried it, it doesn't work. I tried copy-pasting different configs I found on the internet, nothing works

@wjorda
Copy link

wjorda commented Feb 10, 2023

Concur with above, on Helix 22.12 pyright-langserver is nonfunctional even with the empty config section. Have tried a bunch of configs with no success.

Using @the-mikedavis's config (pyright==1.1.293):

2023-02-09T23:54:52.784 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","result":[null],"id":1}
2023-02-09T23:54:52.785 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"Starting service instance \"<default>\""}}
2023-02-09T23:54:52.785 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","id":2,"method":"workspace/configuration","params":{"items":[{"scopeUri":"","section":"python"}]}}
2023-02-09T23:54:52.785 helix_term::application [INFO] window/logMessage: LogMessageParams { typ: Info, message: "Starting service instance \"<default>\"" }
2023-02-09T23:54:52.785 helix_term::application [ERROR] received malformed method call from Language Server: workspace/configuration: protocol error: InvalidParams: Invalid params: invalid value: string "", expected relative URL without a base.

Related: microsoft/pyright#4602

@liangch
Copy link

liangch commented Feb 10, 2023

I am on helix 22.12 (882fa11), pyright==1.1.292 (not latest 1.1.293), diagnostics, completion, etc are working.

[[language]]
name = "python"
roots = ["pyrightconfig.json", "pyproject.toml", "."]
file-types = ["py"]
auto-format = false

[language.language-server]
command = "pyright-langserver"
args = ["--stdio"]

[language.config.analysis]
autoSearchPaths = true
diagnosticMode = "workspace"
useLibraryCodeForTypes = true

@schneiderfelipe
Copy link
Contributor

I am on helix 22.12 (882fa11), pyright==1.1.292 (not latest 1.1.293), diagnostics, completion, etc are working.

Same thing here (complete configuration file):

[[language]]
name = "python"
# roots = ["pyproject.toml"]
language-server = { command = "pyright-langserver", args = ["--stdio"] }
# NOTE: the following is important even if config is empty.
config = { }
formatter = { command = "black", args = ["--quiet", "-"] }
auto-format = true

Versions (39e32db):

$ hx --version
helix 22.12 (39e32dbd)

$ pyright --version
pyright 1.1.289

The only thing I wish I could do is to have pyright make typing strict for all code files without having to add # pyright: strict to every single python file I have. Maybe this is a problem with pyright itself? Pylance seems to have it working, but it's closed source.

@thomasaarholt
Copy link
Contributor

thomasaarholt commented Jul 5, 2023

I'm using the latest main branch (helix 23.05 (57e538d)). Pyright settings in languages.toml don't work. It does work using pyproject.toml and pyrightconfig.json.

If I create a directory foo containing run.py (below), and call either hx foo or hx foo/run.py, I am able to control pyright configs from a foo/pyrightconfig.json. I can also do this with pyproject.toml. If pyrightconfig.json exists, no settings in pyproject.toml take 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.toml at 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.py file to test if the configs take effect

# run.py
import library_that_doesnt_exist # raises a reportMissingImports error
a: str = 42 # should raise a type error when typeCheckingMode is `"basic"` or `"strict"`, not if its `"off"`

Here's the languages.toml I've tried.

[[language]]
name = "python"
scope = "source.python"
injection-regex = "python"
file-types = ["py","pyi","py3","pyw",".pythonstartup",".pythonrc"]
shebangs = ["python"]
roots = ["pyproject.toml", "pyrightconfig.json", "."]
comment-token = "#"
language-servers = [ "pyright" ]
indent = { tab-width = 4, unit = "    " }

[language-server.pyright]
command = "pyright-langserver"
args = ["--stdio"]
# config = {} 

# The following title with values commented out is equivalent to `config = {}` above.
[language-server.pyright.config]
typeCheckingMode = "off"
reportMissingImports = false

# I don't think this one should work, but I tested it anyway
# [language-server.pyright.config.analysis]
# typeCheckingMode = "off"
# reportMissingImports = false

This is the pyproject.toml I've tried:

[tool.pyright]
# typeCheckingMode = "off"
reportMissingImports = "none"

and the pyrightconfig.json:

{
  "typeCheckingMode": "off"
}

I'd appreciate anyone else's input on this!

  • Log showing that 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 with hx --vvv run.py, then opened the log with :log-open, then turned on soft wrap with :set soft-wrap.enable true)

@thomasaarholt
Copy link
Contributor

Figured it out from looking at some vim setups: You have to specify the full pyright.config.python.analysis path in the config: 😅

[language-server.pyright.config.python.analysis]
typeCheckingMode = "off"

@thomasaarholt
Copy link
Contributor

thomasaarholt commented Jul 8, 2023

@schneiderfelipe, the following config makes pyright type check in strict mode:

[language-server.pyright]
command = "pyright-langserver"
args = ["--stdio"]

[language-server.pyright.config.python.analysis]
typeCheckingMode = "strict"
image

@schneiderfelipe
Copy link
Contributor

@schneiderfelipe, the following config makes pyright type check in strict mode:

[language-server.pyright]
command = "pyright-langserver"
args = ["--stdio"]

[language-server.pyright.config.python.analysis]
typeCheckingMode = "strict"
image

Excellent, works perfectly! Thanks!

@David-Else
Copy link
Contributor

David-Else commented Nov 17, 2023

@thomasaarholt In the most recent Helix this is included:

pyright = { command = "pyright-langserver", args = ["--stdio"], config = {} }

but when I add

[language-server.pyright.config.python.analysis]
typeCheckingMode = "strict"

To my languages.toml I don't get any type checking :( Do you know if something changed?

The pyproject.toml method still works.

@thomasaarholt
Copy link
Contributor

thomasaarholt commented Nov 26, 2023

@David-Else, here's my current config, which does give me type checking.

[[language]]
name = "python"
scope = "source.python"
language-servers = ["pyright"]
# I've removed some additional settings here, but they should be irrelevant.

[language-server.pyright]
command = "pyright-langserver"
args = ["--stdio"]

[language-server.pyright.config]
reportMissingTypeStubs = false

[language-server.pyright.config.python.analysis]
typeCheckingMode = "basic"
autoImportCompletions = true

My full config is here in a gist.

I actually came here because I seem to no longer get documentation on hover when I press <space>k. The issue (which I literally just realised) was the ordering of my language servers. Maybe you have something related?

In the first part of the above config, I had:

[[language]]
name = "python"
scope = "source.python"
language-servers = ["ruff", "pyright"]

Changing to

[[language]]
name = "python"
scope = "source.python"
language-servers = ["pyright", "ruff"]

I realised this by calling hx -v myfile.py and navigating to a function I wanted the definition of. Then opening another instance of helix and opening the logs with :log-open, then %d and :w to delete everything and save. Then in the python file I pressed <space>k. In the log window, calling :reload in order to see the updated log, I got these three lines:

2023-11-26T14:28:43.935 helix_lsp::transport [INFO] ruff -> {"jsonrpc":"2.0","method":"textDocument/hover","params":{"position":{"character":18,"line":57},"textDocument":{"uri":"file:///Users/thomas/repos/patito/src/patito/pydantic.py"}},"id":3}
2023-11-26T14:28:43.937 helix_lsp::transport [INFO] ruff <- {"id": 3, "jsonrpc": "2.0", "result": null}
2023-11-26T14:28:43.937 helix_lsp::transport [INFO] ruff <- null

Here I realised that pyright wasn't mentioned at all, but ruff was. Then I tried swapping the order of arguments, and tada!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug upstream
Projects
None yet
Development

No branches or pull requests