diff --git a/lua/config/statusline.lua b/lua/config/statusline.lua index 1a521a66..e170df4c 100644 --- a/lua/config/statusline.lua +++ b/lua/config/statusline.lua @@ -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, @@ -116,6 +137,10 @@ require("lualine").setup { "diff", source = diff, }, + { + virtual_env, + color = { fg = 'black', bg = "#F1CA81" } + } }, lualine_c = { "filename",