Skip to content

Commit

Permalink
Show Py virtual env on statusline
Browse files Browse the repository at this point in the history
  • Loading branch information
jdhao committed Sep 28, 2023
1 parent eccdc62 commit 3137850
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions lua/config/statusline.lua
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,27 @@ local diff = function()
return info
end

local virtual_env = function()
-- only show virtual env for Python
if vim.bo.filetype ~= 'python' then
return ""
end

local conda_env = os.getenv('CONDA_DEFAULT_ENV')
local venv_path = os.getenv('VIRTUAL_ENV')

if venv_path == nil then
if conda_env == nil then
return ""
else
return string.format(" %s (conda)", conda_env)
end
else
local venv_name = vim.fn.fnamemodify(venv_path, ':t')
return string.format(" %s (venv)", venv_name)
end
end

require("lualine").setup {
options = {
icons_enabled = true,
Expand All @@ -116,6 +137,10 @@ require("lualine").setup {
"diff",
source = diff,
},
{
virtual_env,
color = { fg = 'black', bg = "#F1CA81" }
}
},
lualine_c = {
"filename",
Expand Down

0 comments on commit 3137850

Please sign in to comment.