diff --git a/nvim/.config/nvim/lua/plugins/ui.lua b/nvim/.config/nvim/lua/plugins/ui.lua index bdc2974..75da4b5 100644 --- a/nvim/.config/nvim/lua/plugins/ui.lua +++ b/nvim/.config/nvim/lua/plugins/ui.lua @@ -8,26 +8,28 @@ return { -- if molten exists, is initialized and connected to a kernel -- show it in the statusline local function molten() - local function checked_pynvim(_, exitcode) - if exitcode == 0 then - has_pynvim = 1 - else - has_pynvim = 0 - end - end + -- we don't have access to python, disregard element if has_pynvim == 0 then return "" - elseif has_pynvim == -1 then - vim.fn.jobstart({ "python", "-c", "from neovim import VERSION" }, { on_exit = checked_pynvim }) + elseif has_pynvim == 1 then + local status_ok, res = pcall(function() + return require("molten.status").kernels() ~= "" + end) + if status_ok and res then + return "󱪄" + end + return "" + -- we don't know if we have python yet, start a check + else + vim.system({ "poetry", "env", "info", "-p" }, { text = true }, function(_, exitcode) + if exitcode == 0 then + has_pynvim = 1 + else + has_pynvim = 0 + end + end) + has_pynvim = 0 end - if - has_pynvim == 1 - and require("core.util").is_available("molten.status") - and require("molten.status").kernels() ~= "" - then - return "󱪄" - end - return "" end -- count number of selected lines and characters