mirror of
https://github.com/jdhao/nvim-config.git
synced 2025-06-08 14:14:33 +02:00
Show Py virtual env on statusline
This commit is contained in:
parent
eccdc62f38
commit
3137850db6
@ -97,6 +97,27 @@ local diff = function()
|
|||||||
return info
|
return info
|
||||||
end
|
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 {
|
require("lualine").setup {
|
||||||
options = {
|
options = {
|
||||||
icons_enabled = true,
|
icons_enabled = true,
|
||||||
@ -116,6 +137,10 @@ require("lualine").setup {
|
|||||||
"diff",
|
"diff",
|
||||||
source = diff,
|
source = diff,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
virtual_env,
|
||||||
|
color = { fg = 'black', bg = "#F1CA81" }
|
||||||
|
}
|
||||||
},
|
},
|
||||||
lualine_c = {
|
lualine_c = {
|
||||||
"filename",
|
"filename",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user