zbelial / lspce

LSP Client for Emacs implemented as a module using rust.
GNU General Public License v3.0
154 stars 11 forks source link

lspce doesn't work with pyright from homebrew #40

Closed alkurbatov closed 1 month ago

alkurbatov commented 1 month ago

Steps to reproduce:

  1. Install pyright using homebrew:
    brew install pyright
$ pyright --version
pyright 1.1.370
  1. Enable pyright in the config, e.g.:

    (add-to-list 'lspce-server-programs '("python" "pyright" ""))
  2. Open Python file:

    
    from signal import SIGTERM
    import pandas as pd
    import baostock as bs

from pandas import DataFrame

def main() -> int: d = DataFrame() lg = bs.login() print("AAAA") return 0

main()


As a result, Emacs hangs for long time and gives this message:
`[lspce] [WARN] 2024-07-07 14:10:01.397 Failed to connect to lsp server.`

Up:
Added lspce logs:

2024-07-07 14:13:41.743 - start initializing server for lsp_type python in project file:///Users/alkurbatov/work/src/github.com/alkurbatov/tttt 2024-07-07 14:13:41.743 - emacs_exec_path: 2024-07-07 14:13:41.743 - initialize request "{\"id\":\"1000000001\",\"method\":\"initialize\",\"request_tick\":\"91/Users/alkurbatov/work/src/github.com/alkurbatov/tttt/tttt/main.py\",\"params\":{\"processId\":94493,\"rootUri\":\"file:///Users/alkurbatov/work/src/github.com/alkurbatov/tttt\",\"capabilities\":{\"workspace\":{\"applyEdit\":false,\"executeCommand\":{\"dynamicRegistration\":false},\"workspaceEdit\":{\"documentChanges\":true,\"resourceOperations\":[\"create\",\"rename\",\"delete\"]},\"didChangeConfiguration\":{\"dynamicRegistration\":false},\"symbol\":{\"dynamicRegistration\":false},\"configuration\":false,\"workspaceFolders\":false},\"textDocument\":{\"synchronization\":{\"dynamicRegistration\":false,\"willSave\":true,\"didSave\":true},\"completion\":{\"dynamicRegistration\":false,\"completionItem\":{\"snippetSupport\":false,\"commitCharactersSupport\":false,\"documentationFormat\":[\"markdown\",\"plaintext\"],\"deprecatedSupport\":true,\"tagSupport\":{\"valueSet\":[1]},\"preselectSupoort\":false,\"insertReplaceSupport\":false,\"resolveSupport\":{\"properties\":[\"documentation\",\"details\",\"additionalTextEdits\"]}},\"contextSupport\":true},\"hover\":{\"dynamicRegistration\":false,\"contentFormat\":[\"markdown\",\"plaintext\"]},\"signatureHelp\":{\"dynamicRegistration\":false,\"signatureInformation\":{\"documentationFormat\":[\"markdown\",\"plaintext\"],\"parameterInformation\":{\"labelOffsetSupport\":false},\"activeParameterSupport\":false},\"contextSupport\":false},\"references\":{\"dynamicRegistration\":false},\"definition\":{\"dynamicRegistration\":false,\"linkSupport\":false},\"declaration\":{\"dynamicRegistration\":false,\"linkSupport\":false},\"implementation\":{\"dynamicRegistration\":false,\"linkSupport\":false},\"typeDefinition\":{\"dynamicRegistration\":false,\"linkSupport\":false},\"documentHighlight\":{\"dynamicRegistration\":false},\"codeAction\":{\"dynamicRegistration\":false,\"codeActionLiteralSupport\": {\"codeActionKind\":{\"valueSet\":[\"quickfix\",\"refactor\",\"refactor.extract\",\"refactor.inline\",\"refactor.rewrite\",\"source\",\"source.organizeImports\"]}},\"isPreferredSupport\":true,\"disabledSupport\":false,\"dataSupport\":false},\"formatting\":{\"dynamicRegistration\":false},\"rangeFormatting\":{\"dynamicRegistration\":false},\"rename\":{\"dynamicRegistration\":false,\"prepareSupport\":false,\"honorsChangeAnnotations\":false},\"inlayHint\":{\"dynamicRegistration\":false},\"publishDiagnostics\":{\"relatedInformation\":false,\"codeDescriptionSupport\":false,\"codeDescriptionSupport\":false,\"dataSupport\":false,\"versionSupport\":false,\"tagSupport\":{\"valueSet\":[1,2]}},\"callHierarchy\":{\"dynamicRegistration\":false}},\"experimental\":{}},\"clientInfo\":{\"name\":\"lspce\",\"version\":\"1.1.0\"}}}" 2024-07-07 14:13:42.441 - stdio read error malformed header: "/Users/alkurbatov/work/src/github.com/alkurbatov/tttt/tttt/main.py\n" 2024-07-07 14:13:42.441 - Response 2024-07-07 14:13:42.441 - No request tick for id 1 2024-07-07 14:13:42.441 - stdio read error malformed header: " /Users/alkurbatov/work/src/github.com/alkurbatov/tttt/tttt/main.py:2:8 - error: Import \"pandas\" could not be resolved (reportMissingImports)\n" 2024-07-07 14:13:42.441 - stdio read error malformed header: " /Users/alkurbatov/work/src/github.com/alkurbatov/tttt/tttt/main.py:3:8 - error: Import \"baostock\" could not be resolved (reportMissingImports)\n" 2024-07-07 14:13:42.442 - stdio read error malformed header: " /Users/alkurbatov/work/src/github.com/alkurbatov/tttt/tttt/main.py:5:6 - error: Import \"pandas\" could not be resolved (reportMissingImports)\n" 2024-07-07 14:13:42.442 - Response 2024-07-07 14:13:42.442 - No request tick for id 1 2024-07-07 14:13:42.442 - Response 2024-07-07 14:13:42.442 - No request tick for id 1 2024-07-07 14:13:42.442 - Response 2024-07-07 14:13:42.442 - No request tick for id 1 2024-07-07 14:13:42.442 - stdio read error malformed header: "3 errors, 0 warnings, 0 informations \n" 2024-07-07 14:13:42.442 - Response 2024-07-07 14:13:42.442 - No request tick for id 1 2024-07-07 14:13:42.450 - stderr reach EOF 2024-07-07 14:13:42.450 - stderr reach EOF



And lots of `stderr reach EOF` for ~300MB.
zbelial commented 1 month ago

Could you try using the following config and test again? pyright needs some cmd line arguments.

(add-to-list 'lspce-server-programs '("python" "pyright-langserver" "--stdio"))
alkurbatov commented 1 month ago

Thank you! Yeah, now it works. But I would suggest to handle that "stderr reach EOF" since it spams a lot.

zbelial commented 1 month ago

But I would suggest to handle that "stderr reach EOF" since it spams a lot.

You're welcome. I found this problem too and I have commented that line locally. I'll push it upstream.