Closed mohit2152sharma closed 6 months ago
Ok thank you. Sorry for late response, it's been busy over here lately. I will have a look at this one as soon as possible. :)
Sorry for the delays on this one. I managed to catch a very bad cold for the last week here, so haven't been at my computer for almost a week now. Hopefully soon I can have a look at this and figure out what's going on. I didn't write the code for VenvselectCached myself, it was a PR by another user a long time ago, so I have to look into it a bit and see what could be the issue. :)
Hey, no issues, please take care of your health. It's not blocking anything for me, so it's okay if takes time. No need to rush, at the cost of your health.
Are you running the VenvSelectCached
command directly?
If so, this happens because lazy.nvim
loads the plugin lazily, so the commands are not loaded on startup. You can only run the VenvSelectCached
command only after the plugin is loaded.
I can come up with 3 solutions:
VenvSelect
. Lazy loads the plugin when you press the keylua require("venv-selector").retrieve_from_cache()
, the require essential loads the pluginlazy = false
to your config to avoid lazy loading the pluging (https://github.com/folke/lazy.nvim#-plugin-spec)There are probably more solutions. I imagine adding an event trigger to your config could also work, though I could not get it to work for me immediately.
Hope this helps!
@mennohofste For me both of the commands are not working, I tried all your suggestions, but to no avail. Any other suggestions?
@mennohofste , thanks a lot. The issue was exactly, what you explained. I went ahead with option 3 for the time being, but as I am reading more about lua
, I feel like there should be a way to automatically load the virtual environment, when you cd into a project directory (if it's available in cache).. I was able to do that by modifying the config function, now whenever I cd
into a known directory, it automatically loads the virtual environment. I am using the following setup.
{
"linux-cultist/venv-selector.nvim",
lazy = false,
config = function()
local venv = require "venv-selector"
venv.setup {
search = false,
anaconda_envs_path = os.getenv "HOME" .. "/miniconda3/envs",
auto_refresh = true,
search_workspace = false,
}
venv.retrieve_from_cache()
end,
keys = {
{ "<leader>lv", "<cmd>:VenvSelect<cr>", desc = "Select VirtualEnv" },
{ "<leader>lc", "<cmd>:VenvSelectCached<cr>", desc = "Select Cached VirtualEnv" },
},
}
@voider1 , it may be because of how you are setting up the plugin (as it was for me), could you share, more details about how you are setting it up?
@voider1 , I am closing this issue, please open a separate issue for your use case
Amazing to see this closed, thanks a lot @mennohofste and @mohit2152sharma for figuring out what the issue was. :)
So I am using miniconda for my virtual environments and I have the plugin set up as follows:
I cd into my python project and select a virtual environment. But when I come back again to that directory, and run the command
VenvSelectCached
it throws the error,Not an editor command
. However, if I select the virtual environment and then runVenvSelectCached
it works fine.Not sure if I am doing everything correct. I don't know know much lua, but when I was browsing through the functions, (this one), it seems to like, we need to pass
cache_file
in theopts
?