CudaText-addons / cuda_lsp

LSP Client plugin for CudaText
2 stars 3 forks source link

My pyright seems not working #185

Closed yecloud closed 1 year ago

yecloud commented 1 year ago

I have followed the steps in the wiki, and the console said: LSP: starting server - Python; root: /Users/zachary/fxenon/crm But the LSP console displays nothing, and no LSP function work (hover, type definition, etc). here is the lsp_pyright.json

{
  "lexers": {
  "Python": "python"
  },
  "cmd_windows": ["pyright-langserver.exe", "--stdio"],
  "cmd_unix": ["/usr/local/bin/pyright-langserver", "--stdio"],
  "cmd_macos": ["/usr/local/bin/pyright-langserver", "--stdio"]
}
Alexey-T commented 1 year ago

You use unix version . Try to see what Terminal shows when you run this command by hands:

"/usr/local/bin/pyright-langserver --stdio”

veksha commented 1 year ago

lip_pyright.json

must be lsp_*.json, not lip.

is it working when you run it from terminal? add "log_stderr": true, and try again.

yecloud commented 1 year ago

You use unix version . Try to see what Terminal shows when you run this command by hands:

"/usr/local/bin/pyright-langserver --stdio”

iMac27:~ zachary$ /usr/local/bin/pyright-langserver --stdio
Content-Length: 119

{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"Pyright language server 1.1.313 starting"}}Content-Length: 174

{"jsonrpc":"2.0","method":"window/logMessage","params":{"type":3,"message":"Server root directory: /usr/local/Cellar/pyright/1.1.313/libexec/lib/node_modules/pyright/dist/"}}
yecloud commented 1 year ago

lip_pyright.json

must be lsp_*.json, not lip.

is it working when you run it from terminal? add "log_stderr": true, and try again.

env: node: No such file or directory

How to setup node path?

veksha commented 1 year ago

how did you install node? why it's not in Path?

yecloud commented 1 year ago

how did you install node? why it's not in Path?

I installed node from homebrew. It's in PATH and I can call it from terminal. Why can't LSP find it? And I can call node in terminal+ It seems LSP does not load the system PATH

veksha commented 1 year ago

i had problem with nodeenv certificate on my virtual macos machine. fixed it and pyright works ok now.

@yecloud , what output do you have after you call this command: nodeenv env ?

if certificate error, try to fix it with the following command: /Applications/Python\ 3.10/Install\ Certificates.command

image

veksha commented 1 year ago

BTW, pyright will install node inside it's own nodeenv folder.

# you can also try to delete `/Users/yura/.cache/pyright-python/...` dir and try again.
yecloud commented 1 year ago

BTW, pyright will install node inside it's own nodeenv folder.

# you can also try to delete `/Users/yura/.cache/pyright-python/...` dir and try again.

I fixed the certificate and nothing changed. I guess I should install pyright through pip instead of the homebrew one, will try. ----------------> Yes, I should use the pip pyright instead of the homebrew one. It's now working. I think this should be mentioned in Wiki.

yecloud commented 1 year ago

The LSP is working now, but how to make it work with virtualenv? And the question could be: how to send a config file to LSP server? I have the similar issue in rust-analyzer since linkedProjects is required.

veksha commented 1 year ago

in Command Palette type "readme", then Enter, then select "LSP client". readme file will be opened, scroll to "Server-specific options" section.

you can send settings globally or per project.

maybe better variant will be to create "pyrightconfig.json" file or "pyproject.toml" file. read here: https://github.com/microsoft/pyright/blob/main/docs/configuration.md

Alexey-T commented 1 year ago

I added @veksha 's suggestion to https://wiki.freepascal.org/CudaText_plugins#LSP_server_for_Python.2C_pyright

Alexey-T commented 1 year ago

I have the similar issue in rust-analyzer since linkedProjects is required.

Let’s post rust-analyser question to a new topic. But I fear @veksha don’t use Rust and he don’t know. Closing this issue.