-
-
Notifications
You must be signed in to change notification settings - Fork 48
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
Questions about configuration and improving the README #604
Comments
It's recommend to open vim in your project root, that 1. cd to your project root, 2. open vim. coc-pyright will try to detect the Python from venv to use. From the logs:
I found that you're using VimR to open a project to work, but coc-pyright failed to detect the Python.
This log was came from Pyright, do you have
No.
the
Because https://github.com/microsoft/pyright/blob/main/packages/vscode-pyright/package.json has this.
I don't think there is any difference. You can custom settings by coc-settings.json and pyrightconfig.json, but why are there different subset options on both? I don't know.
Yes, Pyright, mypy, pytype are different static typing check tools for Python. coc-pyright uses Pyright to do type checking and LSP related things like completions, goto definitions etc. You disable Pyright's type checking by
In short, coc-pyright uses Pyright as Language Server, to do completions, goto definitions, find references etc. coc-pyright also provides code formatting by black/yapf and lint from pylint/pytype, you can enable them as you like. (You don't need
I can put them into one output channel, but there're too many logs from different tools, so I separate them into three channels. Pyright logs will go Hope I answered your questions. |
I'd like to point out, just a little bit, that this workspace topic can really be a problem:
So just to assure you folks are inline on that topic, I'm sharing that info above. I don't think it should be needed to cd to a project root first and open vim there for it to work (why? you have to read up those links). It might be recommended just due to a currently, not optimal , implementation. |
@oblitum Definitely agree that requiring Vim to be opened in a particular CWD is not ideal. I don't have this problem with other language servers, and was planning to suggest an alternative once I have time to figure out how they work. |
How they need to work is inside those links. There's a bunch that don't do it right though. So how some given one might work may or may not be correct. |
@oblitum yes, you don't need to cd to your project root, you can Remember that in this case, Pyright may use the wrong Python path for the project, this is the main reason for recommending to open vim in your project root: let coc-pyright to do better Python path detecting. There're so many Python venv tools, pyenv/virtualenv/conda/miniforge etc.
In these cases, you need to find and activate the correct Python for the project, then |
version: [coc.nvim] coc-pyright 1.1.164 with Pyright 1.1.163
I am very confused about the configuration of coc-pyright and think the README could really benefit from some clarification. I would be happy to write a PR with this documentation, but I have some questions:
1. How does the
coc-pyright
concept of a "service" relate to a "workspace"?When I open a fresh instance of nvim (I use the VimR GUI on macOS) and then open a file in a Python project (
mosaic
), this is the output I get fromCocCommand workspace.showOutput pyright
:And for every additional Python project I open in the same instance, I get more log messages like
Setting pythonPath for service <project-name>
. So it looks likecoc-pyright
scans each new project opened and calls it aservice
(it does this even for non-python projects).Given that
pythonPath
is resolved with respect to the root of each open project ("service"), what is the role of the "Workspace" in the top line of the log? Despite the fact that my home folder is announced as "Workspace", my home folder: (a) does not show up inCocList folders
(so it's not considered by CoC to be a "workspace folder"); (b) Doesn't actually contain a venv at.venv/bin/python
that it says it's using.2. Does
coc-pyright
maintain separation of different projects with different virtualenvs?e.g. If I open two projects A and B simultaneously in a single Vim instance, each with their own virtualenv, will completion options inside a project A file reflect the project A venv while those inside a project B file reflect the project B venv? Or will the two projects be considered part of a "multi-root" workspace, with the most recently recognized environment overwriting the last recognized one?
3. What is the logic used to determine the Python environment used by
coc-pyright
from configuration parameters? Is the environment the same for the language server, linting, and formatting functionality?coc-pyright
provides the settingspythonPath
andvenvPath
(novenv
).venv
andvenvPath
(nopythonPath
).venvPath
is defined with respect tovenv
--venvPath
is a directory containing virtual envs andvenv
names a specific virtual env. This makes sense. Butcoc-pyright
just gives youvenvPath
but doesn't let you name an actual virtual env. What is the point of this? Under what conditions would I want to setvenvPath
incoc-settings.json
?pythonPath
incoc-settings.json
andvenv
/venvPath
inpyrightconfig.json
-- what happens then?Furthermore, it seems like
coc-pyright
uses different logic to determine the environment depending on the exact bit of functionality requested. For instance, when I start editing a Python project with a virtual env that hasrope
installed, completions etc seem to work well, i.e. the configured virtual env is being used. But when I try to auto-import with a code action, I get an error message saying thatrope
is not installed in the current environment, despite the fact that it is.But if I then restart the server, I get a new log message saying
Workspace: <path-to-project>
, and then I can format with rope. So the completion functionality seems to work based on the project-specific venv discovered in the "service" log message, but external executables (likerope
) aren't resolved w.r.t. this environment, but rather the path announced as the "Workspace".4. Why does the configuration for
coc-pyright
support a small subset of the configuration parameters defined forPyRight
itself? Is there any difference between setting a value incoc-settings.json
vspyrightconfig.json
?For example, useLibraryCodeForTypes can be set either through
coc-settings.json
(viapython.analysis.useLibraryCodeForTypes
) or inpyrightconfig.json
. Does it make a difference where it is set? If not, then why is this parameter exposed incoc-pyright
at all, given that the vast majority of otherPyRight
config parameters cannot be set incoc-settings.json
?5. Why are there configuration settings for
mypy
andpytype
? Aren't these alternative Python type checkers that compete directly with PyRight?Why would I use
mypy
andPyRight
at the same time? And if this project is intended to allow you to choose an arbitrary type checker, then why is there no option to disablePyRight
type-checking, and why is the project calledcoc-pyright
?6. Why are there 3 different output channels (
Pyright
, 'coc-pyright-formatting,
coc-pyright-linting`). Under what circumstances will a log message appear in which channel?The text was updated successfully, but these errors were encountered: