Closed dbragdonmw closed 1 year ago
after saving a file three times in a row
Can you do a test with :noa w
to do saving?
From your settings, you have enabled black
formatter, coc-pyright will run black
on saving. And I found python.linting.enabled
in your coc-settings.json, but didn't find any linter enabled.
Try coc-pyright v1.1.296
Hi, thank you for your help. I updated to v1.1.296. To answer your first comment, I tried :noa w
and it seems like that's stopping my CPU usage from spiking when saving, although I'm still getting decently high spikes here and there just from opening the file (around ~25%) although that might be unrelated.
As for my linting, I have this in my `.init.vim:
augroup black_on_save
autocmd!
autocmd BufWritePre *.py Black
autocmd BufWritePre *.py Isort
augroup end
It runs black and Isort for me, unrelated to the language server I'm using.
Now that I've updated, it seems like the resources aren't as strained. When I save multiple times in a row now I'm still getting around ~20% CPU usage, which isn't ideal, but much lower than 80%. My CPU is pretty powerful so I do think it's still somewhat of an issue that I'm even hitting 20% from saving a file in neovim. I also know that pyright is doing a lot in the background, and again I'm not even sure if this is a coc-pyright issue or just a pyright issue.
autocmd BufWritePre *.py Black
You run black with this autocmd, you should disable formatting by coc-pyright, set python.formatting.provider
to none
.
Hello, I'm running into an issue where pyright is using way too many resource when editing files. Here's my resource usage after saving a file three times in a row:
What's the output of
:CocCommand pyright.version
coc-pyright 1.1.293 with Pyright 1.1.294
What's the output of
:CocCommand workspace.showOutput Pyright
Here is my
coc-config.json
:For some background, I am using PEP 582, meaning that my project's dependencies are contained in the
__pypackages__
folder. I believe that pyright is scanning all of these files every time it starts linting. If I remove__pypackages__
from my working directory, the resource issue seems to go away. Likewise, if I remove"python.analysis.extraPaths": ["__pypackages__/3.10/lib"],
from mycoc-config.json
, the problem doesn't occur. The problem though is that I do need this folder to be searched for auto import completion and such. If I removed the above line from mycoc-config.json
, then I get a warning like this from the linter:since it is no longer checking the
__pypackages__
directory to find the current project's dependencies.Is there a setting I can add to my
coc-config.json
that ignores this folder when linting? Is there something else I can do to fix this issue? Any help would be appreciated.I want to say too that I'm not sure if this is particularly a coc-pyright issue, more than it is a general pyright issue. I'm mostly curious if coc-pyright exposes a feature of pyright that ignores certain directories during the linting process.
Edit: Just tried adding the following to my
pyrightconfig.json
in the root of my project:This did not fix the resource issue. I think pyright is still combing through the
__pypackages__
folder, as stated in the pyright config documentation:"Note that files in the exclude paths may still be included in the analysis if they are referenced (imported) by source files that are not excluded."