nvim: once helper

This commit is contained in:
Primrose 2025-07-28 00:23:02 +02:00
parent a7ebfdd5f5
commit b9fae994cb
Signed by: primrose
GPG key ID: 4E887A4CA9714ADA

15
.config/nvim/lua/once.lua Normal file
View file

@ -0,0 +1,15 @@
-- 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