Skip to content

Commit

Permalink
feat: added support for nvim --headless "+Lazy! sync" +qa
Browse files Browse the repository at this point in the history
  • Loading branch information
folke committed Dec 21, 2022
1 parent bc61747 commit 2e14a2f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 21 deletions.
38 changes: 22 additions & 16 deletions lua/lazy/core/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ M.me = nil
---@type string
M.mapleader = nil

M.headless = #vim.api.nvim_list_uis() == 0

---@param spec LazySpec
---@param opts? LazyConfig
function M.setup(spec, opts)
Expand Down Expand Up @@ -153,22 +155,26 @@ function M.setup(spec, opts)
vim.go.loadplugins = false
M.mapleader = vim.g.mapleader

vim.api.nvim_create_autocmd("User", {
pattern = "VeryLazy",
once = true,
callback = function()
require("lazy.core.cache").autosave()
require("lazy.view").setup()
if M.options.change_detection.enabled then
require("lazy.manage.reloader").enable()
end
if M.options.checker.enabled then
vim.defer_fn(function()
require("lazy.manage.checker").start()
end, 10)
end
end,
})
if M.headless then
require("lazy.view.commands").setup()
else
vim.api.nvim_create_autocmd("User", {
pattern = "VeryLazy",
once = true,
callback = function()
require("lazy.core.cache").autosave()
require("lazy.view.commands").setup()
if M.options.change_detection.enabled then
require("lazy.manage.reloader").enable()
end
if M.options.checker.enabled then
vim.defer_fn(function()
require("lazy.manage.checker").start()
end, 10)
end
end,
})
end

Util.very_lazy()
end
Expand Down
8 changes: 3 additions & 5 deletions lua/lazy/view/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,10 @@ M.hover = "K"
---@type string?
M.mode = nil

function M.setup()
require("lazy.view.commands").setup()
require("lazy.view.colors").setup()
end

function M.show(mode)
if Config.headless then
return
end
M.mode = mode or M.mode or "home"
require("lazy.view.colors").setup()

Expand Down

0 comments on commit 2e14a2f

Please sign in to comment.