diff --git a/nvim/.config/nvim/lua/plugins/ui.lua b/nvim/.config/nvim/lua/plugins/ui.lua index 7026909..73c1a4c 100644 --- a/nvim/.config/nvim/lua/plugins/ui.lua +++ b/nvim/.config/nvim/lua/plugins/ui.lua @@ -4,16 +4,31 @@ return { "nvim-lualine/lualine.nvim", dependencies = { { "nvim-tree/nvim-web-devicons", config = true } }, config = function() - -- FIXME: Errors out on no pynvim installed - -- local function molten() - -- if - -- require("core.util").is_available("molten.status") - -- and require("molten.status").initialized() ~= "" - -- then - -- return "󱪄" - -- end - -- return "" - -- end + local has_pynvim = -1 + -- 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 + if has_pynvim == 0 then + return "" + elseif has_pynvim == -1 then + vim.fn.jobstart({ "python", "-c", "from neovim import VERSION" }, { on_exit = checked_pynvim }) + end + if + has_pynvim == 1 + and require("core.util").is_available("molten.status") + and require("molten.status").kernels() ~= "" + then + return "󱪄" + end + return "" + end require("lualine").setup({ options = { icons_enabled = true, @@ -27,7 +42,7 @@ return { lualine_a = { "mode" }, lualine_b = { "branch", "diff", "diagnostics" }, lualine_c = { "filename" }, - lualine_x = { "encoding", "fileformat", "filetype", "molten" }, + lualine_x = { "encoding", "fileformat", "filetype", molten }, lualine_y = { "progress" }, lualine_z = { "location" }, },