From 05b55deb16f074f2a44b81927c2e5feb63fba651 Mon Sep 17 00:00:00 2001 From: Brian Koropoff Date: Sat, 7 Jan 2023 00:01:45 -0800 Subject: [PATCH] fix(config): Don't cache check for attached UIs (#340) UIs can attach and detach from headless nvim dynamically (indeed, this is one of its use cases). --- lua/lazy/core/config.lua | 6 ++++-- lua/lazy/view/init.lua | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lua/lazy/core/config.lua b/lua/lazy/core/config.lua index f5441e0..c83a09a 100644 --- a/lua/lazy/core/config.lua +++ b/lua/lazy/core/config.lua @@ -159,7 +159,9 @@ M.me = nil ---@type string M.mapleader = nil -M.headless = #vim.api.nvim_list_uis() == 0 +function M.headless() + return #vim.api.nvim_list_uis() == 0 +end ---@param opts? LazyConfig function M.setup(opts) @@ -200,7 +202,7 @@ function M.setup(opts) vim.go.loadplugins = false M.mapleader = vim.g.mapleader - if M.headless then + if M.headless() then require("lazy.view.commands").setup() else vim.api.nvim_create_autocmd("UIEnter", { diff --git a/lua/lazy/view/init.lua b/lua/lazy/view/init.lua index 0f4e0d2..ac64e74 100644 --- a/lua/lazy/view/init.lua +++ b/lua/lazy/view/init.lua @@ -31,7 +31,7 @@ end ---@param mode? string function M.show(mode) - if Config.headless then + if Config.headless() then return end