Closed mennohofste closed 6 months ago
I think #58 can be closed now. 😄
I removed theM.set_pythonpath
function locally and could not find any difference in behaviour. From reading the function that would make sense, as its purpose is superceded by hooks.
Could someone else test this as well? Maybe there is some edge case I did not think of. Otherwise, I can submit a PR to remove the duplicate code.
Found the problem a few months ago. And, I also thought M.set_pythonpath
is redundant. So I attempted to remove M.set_pythonpath
at that time, no issue occurred too.
Thanks guys. Sounds good to make a PR to remove it.
I guess it's just a leftover and I admit I haven't put time into looking over all the code in a while now, so it's great that you guys are doing it. :)
The Python path is changed twice, once by venv.set_pythonpath, and once with the hooks. The
set_pythonpath
creates an autocommand that changes the config every time a file is loaded. This is spin-off issue of #58.Hooks: https://github.com/linux-cultist/venv-selector.nvim/blob/main/lua/venv-selector/hooks.lua
venv.set_pythonpath
: https://github.com/linux-cultist/venv-selector.nvim/blob/main/lua/venv-selector/venv.lua#L186C1-L213C1Hooks:
venv.set_pythonpath
:An autocommand runs every time the event is triggered.
BufReadPost
is ran when starting to edit a new buffer, after reading the file into the buffer, processing modelines. I do not understand why this is here, aspyright
should stay active with the last set settings, so resetting every time a new buffer opens seems redundant. It could be overriding other plugins changing the python path as @cmetz wrote.Even then, only one autocommand is necessary creating a new one every time the venv changes. Maybe there is a way to change an existing autocommand, if it is necessary.
I will experiment a bit to try and understand this better. Any hints or feedback is welcome.