diff options
| author | jdhao <jdhao@hotmail.com> | 2023-09-28 09:41:36 +0200 |
|---|---|---|
| committer | jdhao <jdhao@hotmail.com> | 2023-09-28 09:42:27 +0200 |
| commit | 3137850db67b1b45111656e8749b60eb936dfa7d (patch) | |
| tree | 67a34cc78b558655f13ecc03c45fe91bedda0da1 /lua | |
| parent | eccdc62f38bfcff65904b864d16b24f5cd64e3c4 (diff) | |
Show Py virtual env on statusline
Diffstat (limited to 'lua')
| -rw-r--r-- | lua/config/statusline.lua | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/lua/config/statusline.lua b/lua/config/statusline.lua index 1a521a6..e170df4 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", |
