refactor(nvim): improve handling of alpha date timer
This commit is contained in:
parent
6ba0c3e860
commit
aa6af5408c
@ -171,10 +171,10 @@ return {
|
|||||||
},
|
},
|
||||||
opts = { margin = 5 },
|
opts = { margin = 5 },
|
||||||
}
|
}
|
||||||
vim.api.nvim_create_autocmd("FileType", {
|
vim.api.nvim_create_autocmd("User", {
|
||||||
pattern = "alpha",
|
pattern = "AlphaReady",
|
||||||
desc = "Alpha Main Handler",
|
desc = "Alpha Main Handler",
|
||||||
callback = function()
|
callback = function(args)
|
||||||
vim.opt_local.cursorline = false
|
vim.opt_local.cursorline = false
|
||||||
|
|
||||||
local alpha_timer = vim.loop.new_timer()
|
local alpha_timer = vim.loop.new_timer()
|
||||||
@ -187,12 +187,14 @@ return {
|
|||||||
end)
|
end)
|
||||||
)
|
)
|
||||||
|
|
||||||
vim.api.nvim_create_autocmd("BufUnload", {
|
vim.api.nvim_create_autocmd("User", {
|
||||||
buffer = 0,
|
pattern = "AlphaClosed",
|
||||||
desc = "Shut down alpha timer",
|
desc = "Shut down alpha timer",
|
||||||
callback = function()
|
callback = function()
|
||||||
---@diagnostic disable-next-line: need-check-nil
|
---@diagnostic disable-next-line: need-check-nil
|
||||||
alpha_timer:close()
|
alpha_timer:close()
|
||||||
|
vim.api.nvim_del_autocmd(args.id)
|
||||||
|
return true
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
end,
|
end,
|
||||||
|
Loading…
Reference in New Issue
Block a user