diff --git a/lua/lv-galaxyline/init.lua b/lua/lv-galaxyline/init.lua index 69404b48..6bcf08f5 100644 --- a/lua/lv-galaxyline/init.lua +++ b/lua/lv-galaxyline/init.lua @@ -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 = {