pyright-for-pycharm icon indicating copy to clipboard operation
pyright-for-pycharm copied to clipboard

Configuration file setting is ignored for LSP4IJ mode

Open fkrauthan opened this issue 1 year ago • 5 comments

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 avatar Aug 26 '24 22:08 fkrauthan

Console mode works as expected

fkrauthan avatar Aug 26 '24 22:08 fkrauthan

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.

InSyncWithFoo avatar Aug 26 '24 23:08 InSyncWithFoo

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.

fkrauthan avatar Aug 26 '24 23:08 fkrauthan

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.

InSyncWithFoo avatar Aug 27 '24 01:08 InSyncWithFoo

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.

fkrauthan avatar Aug 27 '24 01:08 fkrauthan