nvim: Fix molten statusline icon

Fixed issue when pynvim did not exist in the environment but we tried to
invoke a molten-nvim command. Now we first fire up python to check for
pynvim existence. This takes a moment so we do it asynchronously and
cache the result for the rest of the program runtime.

Also we only show the molten icon if we are actually connected to a
running kernel.
This commit is contained in:
Marty Oehme 2024-06-17 15:28:09 +02:00
parent 2d513ad74b
commit 0f46dcad28
Signed by: Marty
GPG key ID: EDBF2ED917B2EF6A

View file

@ -4,16 +4,31 @@ return {
"nvim-lualine/lualine.nvim", "nvim-lualine/lualine.nvim",
dependencies = { { "nvim-tree/nvim-web-devicons", config = true } }, dependencies = { { "nvim-tree/nvim-web-devicons", config = true } },
config = function() config = function()
-- FIXME: Errors out on no pynvim installed local has_pynvim = -1
-- local function molten() -- if molten exists, is initialized and connected to a kernel
-- if -- show it in the statusline
-- require("core.util").is_available("molten.status") local function molten()
-- and require("molten.status").initialized() ~= "" local function checked_pynvim(_, exitcode)
-- then if exitcode == 0 then
-- return "󱪄" has_pynvim = 1
-- end else
-- return "" has_pynvim = 0
-- end 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({ require("lualine").setup({
options = { options = {
icons_enabled = true, icons_enabled = true,
@ -27,7 +42,7 @@ return {
lualine_a = { "mode" }, lualine_a = { "mode" },
lualine_b = { "branch", "diff", "diagnostics" }, lualine_b = { "branch", "diff", "diagnostics" },
lualine_c = { "filename" }, lualine_c = { "filename" },
lualine_x = { "encoding", "fileformat", "filetype", "molten" }, lualine_x = { "encoding", "fileformat", "filetype", molten },
lualine_y = { "progress" }, lualine_y = { "progress" },
lualine_z = { "location" }, lualine_z = { "location" },
}, },