Skip to content

Commit

Permalink
feat(calendar): allow many simultaneous calendars
Browse files Browse the repository at this point in the history
  • Loading branch information
vhyrro committed May 14, 2023
1 parent 9751e7d commit f816fe7
Show file tree
Hide file tree
Showing 2 changed files with 363 additions and 350 deletions.
17 changes: 10 additions & 7 deletions lua/neorg/modules/core/ui/calendar/module.lua
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,21 @@ module.private = {
end,

open_window = function(options)
local bufid = vim.fn.bufnr("neorg://calendar")

if bufid ~= -1 then
vim.api.nvim_buf_delete(bufid, { force = true })
end

local buffer, window = module.required["core.ui"].create_split(
"calendar",
"calendar-" .. tostring(os.clock()):gsub("%.", "-"),
{},
options.height or math.floor(vim.opt.lines:get() * 0.3)
)

vim.api.nvim_create_autocmd({ "WinClosed", "BufDelete" }, {
buffer = buffer,

callback = function()
pcall(vim.api.nvim_win_close, window, true)
pcall(vim.api.nvim_buf_delete, buffer, { force = true })
end,
})

return buffer, window
end,
}
Expand Down
Loading

0 comments on commit f816fe7

Please sign in to comment.