Skip to content

Conversation

@palandovalex
Copy link

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.

Copy link
Owner

@AckslD AckslD left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very nice @palandovalex!

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
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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'))
Copy link
Owner

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
end

Copy link
Author

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?

Copy link
Owner

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants