.files/.config/nvim/lua/once.lua
2025-07-28 11:22:02 +02:00

15 lines
321 B
Lua

-- A helper that prevents something to be loaded more than once
M = {}
---@param label string
---@param callback function
function M.test_and_load(label, callback)
local once = vim.g.once or {}
if not once[label] then
callback()
once[label] = true
vim.g.once = once
end
end
return M