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

Pyright not respecting g:WorkspaceFolders #851

Open
cheog opened this issue Nov 20, 2022 · 2 comments
Open

Pyright not respecting g:WorkspaceFolders #851

cheog opened this issue Nov 20, 2022 · 2 comments
Assignees

Comments

@cheog
Copy link

cheog commented Nov 20, 2022

What's the output of :CocCommand pyright.version
coc-pyright 1.1.280 with Pyright 1.1.280

What's the output of :CocCommand workspace.showOutput Pyright

Workspace: /home/me/scratch/monorepo/application
Using python from dist/export/python/virtualenvs/python-default/3.10.2/bin/python

[Info  - 2:28:22 PM] Pyright language server 1.1.280 starting
[Info  - 2:28:22 PM] Server root directory: /home/me/.config/coc/extensions/node_modules/coc-pyright/node_modules/pyright/dist/
[Info  - 2:28:22 PM] Starting service instance "application"
[Info  - 2:28:22 PM] Starting service instance "library"
[Info  - 2:28:22 PM] Starting service instance "service"
[Info  - 2:28:23 PM] Starting service instance "<default>"
[Info  - 2:28:23 PM] No configuration file found.
[Info  - 2:28:23 PM] No pyproject.toml file found.
[Info  - 2:28:23 PM] Setting pythonPath for service "application": "/home/me/scratch/monorepo/application/dist/export/python/virtualenvs/python-default/3.10.2/bin/python"
[Warn  - 2:28:23 PM] stubPath /home/me/scratch/monorepo/application/typings is not a valid directory.
[Info  - 2:28:23 PM] Unable to get Python version from interpreter
[Info  - 2:28:23 PM] Assuming Python platform Linux
[Info  - 2:28:23 PM] Searching for source files
[Info  - 2:28:23 PM] Found 4 source files
[Info  - 2:28:23 PM] No configuration file found.
[Info  - 2:28:23 PM] No pyproject.toml file found.
[Info  - 2:28:23 PM] Setting pythonPath for service "library": "/home/me/scratch/monorepo/library/dist/export/python/virtualenvs/python-default/3.10.2/bin/python"
[Warn  - 2:28:23 PM] stubPath /home/me/scratch/monorepo/library/typings is not a valid directory.
[Info  - 2:28:23 PM] Unable to get Python version from interpreter
[Info  - 2:28:23 PM] Assuming Python platform Linux
[Info  - 2:28:23 PM] Searching for source files
[Info  - 2:28:23 PM] Found 4 source files
[Info  - 2:28:23 PM] No configuration file found.
[Info  - 2:28:23 PM] No pyproject.toml file found.
[Info  - 2:28:23 PM] Setting pythonPath for service "service": "/home/me/scratch/monorepo/service/dist/export/python/virtualenvs/python-default/3.10.2/bin/python"
[Warn  - 2:28:23 PM] stubPath /home/me/scratch/monorepo/service/typings is not a valid directory.
[Info  - 2:28:23 PM] Unable to get Python version from interpreter
[Info  - 2:28:23 PM] Assuming Python platform Linux
[Info  - 2:28:23 PM] Searching for source files
[Info  - 2:28:23 PM] Found 4 source files
[Info  - 2:28:23 PM] No pyproject.toml file found.
[Info  - 2:28:23 PM] Setting pythonPath for service "<default>": "/home/me/scratch/monorepo/application/dist/export/python/virtualenvs/python-default/3.10.2/bin/python"
[Warn  - 2:28:23 PM] stubPath typings is not a valid directory.
[Info  - 2:28:23 PM] Unable to get Python version from interpreter
[Info  - 2:28:23 PM] Assuming Python platform Linux
[Info  - 2:28:23 PM] Searching for source files
[Info  - 2:28:23 PM] No source files found.

Issue

I'm testing a monorepo layout and I can't get pyright to understand where all the roots are.

Details

My repo (tree below) has three major parts: application, library, and service. Each of these is supposed to be kind of self contained with it's own tests, readme, documentation etc.

I have a bit of vimscript that sets g:WorkspaceFolders to be ["/home/me/scratch/monorepo/application", "/home/me/scratch/monorepo/library", "/home/me/scratch/monorepo/service"]. This script runs after I set the keybindings and settings of CoC. However, as you can tell by the logs, it's not using these folders. How do I manually set the workspace folders?

I do not want to use the root_pattern stuff for two reasons:

  1. There isn't a usable root pattern.
  2. Even if there was (like if I did a touch .root in every root folder), it doesn't acknowledge all the roots unless I have at least one file per root open.
.
├── application
│   ├── application
│   │   ├── __init__.py
│   │   └── main.py
│   ├── README.md
│   └── tests
│       ├── __init__.py
│       └── test_application.py
├── default.lock
├── library
│   ├── library
│   │   ├── __init__.py
│   │   └── main.py
│   ├── README.md
│   └── tests
│       ├── __init__.py
│       └── test_library.py
├── pants
├── pants-plugins
│   └── version_from_git
│       ├── __pycache__
│       └── register.py
├── pants.toml
├── pyproject.toml
├── README.md
├── requirements.txt
└── service
    ├── README.md
    ├── service
    │   ├── __init__.py
    │   └── main.py
    └── tests
        ├── __init__.py
        └── test_service.py
@fannheyward
Copy link
Owner

Thanks for your report, I didn't use g:WorkspaceFolders before, will check it, looks like it's coc.nvim side's issue.

@cheog
Copy link
Author

cheog commented Dec 16, 2022

Thanks for taking the time! For now is there another way I can explicitly set the workspace folders I want with vimscript (ie without having to open one file from each folder or put a dummy ".root" or something in each file for the rootPatterns to pick up)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants