-
Notifications
You must be signed in to change notification settings - Fork 31
add ignore_envs_groups parametr #37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
AckslD
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
very nice @palandovalex!
lua/swenv/api.lua
Outdated
| vim.list_extend(venvs, get_venvs_for(get_pyenv_base_path(), 'pyenv', { only_dirs = false })) | ||
|
|
||
| local ignore_envs = to_set(settings.ignore_envs_groups) | ||
| if ignore_envs and not ignore_envs['conda'] then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| if ignore_envs and not ignore_envs['conda'] then | |
| if not ignore_envs['conda'] then |
wouldn't this work as well?
|
|
||
| local ignore_envs = to_set(settings.ignore_envs_groups) | ||
| if ignore_envs and not ignore_envs['conda'] then | ||
| vim.list_extend(venvs, get_venvs_for(get_conda_base_path(), 'conda')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to structure things a bit more, what do you think about moving this to a module level table such as:
local venvs_getters = {
conda = function()
local venvs = {}
vim.list_extend(venvs, get_venvs_for(get_conda_base_path(), 'conda'))
vim.list_extend(venvs, get_conda_base_env())
return venvs
end,
pixi = function()
return get_venvs_for(get_pixi_base_path(), 'pixi')
end,
micromamba = function()
return get_venvs_for(get_micromamba_base_path(), 'micromamba')
end,
pyenv = function()
local venvs = {}
vim.list_extend(venvs, get_venvs_for(get_pyenv_base_path(), 'pyenv'))
vim.list_extend(venvs, get_venvs_for(get_pyenv_base_path(), 'pyenv', { only_dirs = false }))
return venvs
end,
}and then this main function could be something like:
for name, getter in pairs(venvs_getters) do
if not ignore_envs[name] then
vim.list_extend(venvs, getter())
end
endThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May be, may be... Extract this table and venv_getters file ("venv_profiles"), ore some thing other?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, not fully sure what you're asking?
8412c04 to
b90189d
Compare
The author of the plugin noted that the support of many different groups of virtual environments can negatively affect the performance of the plugin. In this regard, I added the "ignore_envs_groups" parameter. this is a table that should contain rows with the names of virtual environment groups. By default, the table is empty so as not to break the backward compatibility of the plugin. But anyone can add to this variable all the groups of environments that they do not use, thereby saving the plugin time.