mirror of
https://github.com/folke/snacks.nvim
synced 2025-08-04 10:49:08 +00:00
fix: simplify setup
This commit is contained in:
parent
73445af400
commit
787b53e763
1 changed files with 12 additions and 26 deletions
|
@ -50,22 +50,22 @@ function M.setup(opts)
|
|||
|
||||
local group = vim.api.nvim_create_augroup("snacks", { clear = true })
|
||||
|
||||
if M.config.bigfile.enabled then
|
||||
vim.api.nvim_create_autocmd("BufReadPre", {
|
||||
group = group,
|
||||
once = true,
|
||||
callback = function()
|
||||
Snacks.bigfile.setup()
|
||||
end,
|
||||
})
|
||||
end
|
||||
local events = {
|
||||
BufReadPre = { "bigfile" },
|
||||
BufReadPost = { "quickfile" },
|
||||
LspAttach = { "words" },
|
||||
}
|
||||
|
||||
if M.config.quickfile.enabled then
|
||||
vim.api.nvim_create_autocmd("BufReadPost", {
|
||||
for event, snacks in pairs(events) do
|
||||
vim.api.nvim_create_autocmd(event, {
|
||||
group = group,
|
||||
once = true,
|
||||
callback = function()
|
||||
Snacks.quickfile.setup()
|
||||
for _, snack in ipairs(snacks) do
|
||||
if M.config[snack].enabled then
|
||||
M[snack].setup()
|
||||
end
|
||||
end
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
@ -73,20 +73,6 @@ function M.setup(opts)
|
|||
if M.config.statuscolumn.enabled then
|
||||
vim.o.statuscolumn = [[%!v:lua.require'snacks.statuscolumn'.get()]]
|
||||
end
|
||||
|
||||
local later = vim.schedule_wrap(function()
|
||||
if M.config.words.enabled then
|
||||
Snacks.words.setup()
|
||||
end
|
||||
end)
|
||||
|
||||
if vim.v.vim_did_enter == 1 then
|
||||
later()
|
||||
else
|
||||
vim.api.nvim_create_autocmd("UIEnter", {
|
||||
callback = later,
|
||||
})
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue