Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions lua/swenv/api.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ local update_path = function(path)
end

local set_venv = function(venv)
if venv.source == 'conda' then
if venv.source == 'conda' or venv.source == 'micromamba' then
vim.fn.setenv('CONDA_PREFIX', venv.path)
vim.fn.setenv('CONDA_DEFAULT_ENV', venv.name)
vim.fn.setenv('CONDA_PROMPT_MODIFIER', '(' .. venv.name .. ')')
Expand Down Expand Up @@ -41,7 +41,7 @@ M.get_venvs = function(venvs_path)
local scan_dir = require('plenary.scandir').scan_dir

local venvs = {}

-- CONDA
local conda_exe = vim.fn.getenv('CONDA_EXE')
if conda_exe ~= vim.NIL then
Expand All @@ -56,6 +56,21 @@ M.get_venvs = function(venvs_path)
})
end
end

--MICROMAMBA
local micromamba_exe = vim.fn.getenv('MAMBA_EXE')
if micromamba_exe ~= vim.NIL then
local micromamba_env_path = Path:new(vim.fn.getenv('MAMBA_ROOT_PREFIX')) .. '/envs'
local micromamba_paths = scan_dir(micromamba_env_path, { depth = 1, only_dirs = true, silent = true })

for _, path in ipairs(micromamba_paths) do
table.insert(venvs, {
name = Path:new(path):make_relative(micromamba_env_path),
path = path,
source = 'micromamba',
})
end
Comment on lines +63 to +72
Copy link
Owner

Choose a reason for hiding this comment

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

SInce this code is mostly shared now by the three cases maybe we can move this out to a separate function taking a path and source? Let me know if you want to do this or I can also do it.

end

-- VENV
local paths = scan_dir(venvs_path, { depth = 1, only_dirs = true, silent = true })
Expand Down