InSyncWithFoo / pyright-for-pycharm

Pyright integration for PyCharm
https://insyncwithfoo.github.io/pyright-for-pycharm/
MIT License
46 stars 0 forks source link

Configuration file setting is ignored for LSP4IJ mode #66

Open fkrauthan opened 2 weeks ago

fkrauthan commented 2 weeks ago

What happened?

When using the LSP4IJ mode the language server is ignoring the Configuration file I manually set and instead uses a pyproject.toml in the root of my project.

Steps to reproduce

  1. Create pyproject.toml` without any pyright specific settings
  2. Create a subfolder my_sub and create a pyrightconfig.json file
  3. Set the Pyright (Project) -> Configuration setting to my_sub/pyrightconfig.json
  4. Set the Running mode to LSP4IJ`
  5. Open a python file and look at the Language Server Logs.

Relevant log output or stack trace

Server root directory: file:///Users/florian.krauthan/.cache/pyright-python/1.1.377/node_modules/pyright/dist
Pyright language server 1.1.377 starting
Starting service instance "..."
Loading pyproject.toml file at /Users/florian.krauthan/Projects/.../pyproject.toml
Pyproject file "/Users/florian.krauthan/Projects/.../pyproject.toml" has no "[tool.pyright]" section.
Auto-excluding **/__pycache__
Auto-excluding **/node_modules
Auto-excluding **/.*
No include entries specified; assuming /Users/florian.krauthan/Projects/...
Auto-excluding /Users/florian.krauthan/Projects/.../my_sub/venv
Found 831 source files

Operating system

macOS

fkrauthan commented 2 weeks ago

Console mode works as expected

InSyncWithFoo commented 2 weeks ago

This is expected. Pyright's LSP mode does not support explicit explicit configuration file. See this discussion. You can file an enhancement request for Pyright, though.

fkrauthan commented 2 weeks ago

Could you not add a working directory setting to the plugin that would be used for executing the language server and the command line? Instead of running it from the project root. At least for my use-case that would solve the issue.

InSyncWithFoo commented 2 weeks ago

That wouldn't work, since LSP mode uses workspace folders and not the working directory. You can try the build out yourself to verify this.

LSP4IJ, which is the client this plugin is using, has yet to support workspace folders, so I'm afraid you will have to wait. I wonder if Pylance supports your use case.

fkrauthan commented 2 weeks ago

Ah ok that make sense. Didn't know that the underlying LSP system does not yet support it.

And yeah I just tested your test build and it does not work. Even though ti seem to run the server in the context of my sub folder it still somehow detects the pyproject.toml of the root folder.