mirror of
https://github.com/LunarVim/LunarVim.git
synced 2024-09-21 02:55:09 +02:00
WIP: show virtualenv inside galaxyline (#767)
This commit is contained in:
parent
51c0f48970
commit
e02c7c5abb
1 changed files with 41 additions and 0 deletions
|
@ -125,6 +125,47 @@ table.insert(gls.left, {
|
|||
highlight = "StatusLineGitDelete",
|
||||
},
|
||||
})
|
||||
-- get output from shell command
|
||||
function os.capture(cmd, raw)
|
||||
local f = assert(io.popen(cmd, 'r'))
|
||||
local s = assert(f:read('*a'))
|
||||
f:close()
|
||||
if raw then return s end
|
||||
s = string.gsub(s, '^%s+', '')
|
||||
s = string.gsub(s, '%s+$', '')
|
||||
s = string.gsub(s, '[\n\r]+', ' ')
|
||||
return s
|
||||
end
|
||||
-- cleanup virtual env
|
||||
function env_cleanup(venv)
|
||||
if string.find(venv, "/") then
|
||||
final_venv = venv
|
||||
for w in venv:gmatch("([^/]+)") do final_venv=w end
|
||||
venv = final_venv
|
||||
end
|
||||
return venv
|
||||
end
|
||||
local PythonEnv = function ()
|
||||
if vim.bo.filetype == 'python' then
|
||||
venv = os.getenv('CONDA_DEFAULT_ENV')
|
||||
if venv ~= nil then
|
||||
return "🅒 " .. env_cleanup(venv)
|
||||
end
|
||||
venv = os.getenv('VIRTUAL_ENV')
|
||||
if venv ~= nil then
|
||||
return "🐍 " .. env_cleanup(venv)
|
||||
end
|
||||
return ''
|
||||
end
|
||||
return ''
|
||||
end
|
||||
table.insert(gls.left, {
|
||||
VirtualEnv = {
|
||||
provider = PythonEnv,
|
||||
highlight = {colors.green, colors.bg},
|
||||
event = 'BufEnter'
|
||||
}
|
||||
})
|
||||
|
||||
table.insert(gls.right, {
|
||||
DiagnosticError = {
|
||||
|
|
Loading…
Reference in a new issue