Closed fxdgear closed 9 months ago
@fxdgear swenv currently assumes that all your venvs is in a single folder. You can however provide your own get_venvs
function to the setup.
Could you help advise me on a function that could do that?
I’m not a lua guy and I’m not sure how to debug it when running in lunarvim.
@fxdgear you could extend the default get_venvs function in your config to add more sources for venvs. For example:
require('swenv').setup({
-- other options
venvs_path = vim.fn.expand('~/venvs'),
get_venvs = function (venvs_path)
local venvs = require('swenv.api').get_venvs()
local more_venvs = {}
local scan_dir = require('plenary.scandir').scan_dir
-- Another venv source
local paths = scan_dir('/path/to/another/venvs/dir', { depth = 1, only_dirs = true, silent = true })
for _, path in ipairs(paths) do
table.insert(more_venvs, {
name = 'venv name',
path = path,
source = '<source name>',
})
end
return vim.tbl_deep_extend("keep", venvs, more_venvs)
end
})
You could also change the venvs_path
option to return a list of sources and change the get_venvs
implementation.
Thank you!! I’ll get to playing with this!!
Sometimes the venv is created through
virtualenv
sometimes it's created throughpoetry
and sometimes it's created throughpipenv
and hell who knows I might even usedpyenv
one day.IF I need to specify lots of different locations for venvs, how can I tell lunarvim where to look for all of em?