reddit / emacs

Pyright not working properly at startup

TheHentaiSama · 2022-11-29 13:12
Hello everyone ! I recently had to update my system and since then I've noticed something odd with pyright. When I open a project and my lsp server starts with pyright, the file I first opened to open the project doesn't work well. I don't get the usual autocompletion, the errors listed by flycheck all appear in the first in the first lines and don't get removed if i correct the acutal error, .... And this only happens in the very first file which started the server ! On top of that I've also noticed that it only happens when I have more than one listed lsp workspace folder using pyright. My current workaround is to kill the buffer and reopen the file again but it would beetter if I could get rid of it entirely. I use doom emacs with pyright and lsp and I also use pyenv for my virtualenvs with the pyenv package which allows emacs to automatically detect the local version I set for a project and use it. It's very weird and I have a hard time finding the root of the problem so if someone had a similar issue at some point or as any clue on what to do it would be very much appreciated !
terminal_cope · 2022-11-30 14:39
Having faced similar problems, I think it's probably that the pyenv package configures the environment after lsp starts. At least it sounds similar to problems I had when relevant environment config for me came from direnv and local variables. I had to *not* enable lsp simplistically for python-mode, and instead make a hook for python mode that initialized the environment first and then launched lsp.
TheHentaiSama · 2022-11-30 14:57
I was starting to think about this. I tried to do some cleanup and update on my pyenv config yesterday just in case but it didn’t change anything. And today when arriving at work the problem was no more ! I’m kind of expecting it to be back tomorrow. If it does I’ll have a look at what you pointed !