Skip to content

Commit

Permalink
fix(config): Don't cache check for attached UIs (#340)
Browse files Browse the repository at this point in the history
UIs can attach and detach from headless nvim dynamically
(indeed, this is one of its use cases).
  • Loading branch information
bkoropoff authored Jan 7, 2023
1 parent 7eadaac commit 05b55de
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions lua/lazy/core/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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", {
Expand Down
2 changes: 1 addition & 1 deletion lua/lazy/view/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ end

---@param mode? string
function M.show(mode)
if Config.headless then
if Config.headless() then
return
end

Expand Down

0 comments on commit 05b55de

Please sign in to comment.