From 8d05fcaaeb1442c709f148ff934d92900743f051 Mon Sep 17 00:00:00 2001 From: Daniil Rozanov Date: Fri, 26 Apr 2024 00:50:04 +0300 Subject: feat: command to edit variants If there is no cmake-variants.yaml file in current directory, command creates it with default variants --- lua/cmake/lazy.lua | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 lua/cmake/lazy.lua (limited to 'lua/cmake/lazy.lua') diff --git a/lua/cmake/lazy.lua b/lua/cmake/lazy.lua new file mode 100644 index 0000000..7669dcd --- /dev/null +++ b/lua/cmake/lazy.lua @@ -0,0 +1,21 @@ +local lazy = {} + +--- Require on index. +--- +--- Will only require the module after the first index of a module. +--- Only works for modules that export a table. +---@param require_path string +---@return table +lazy.require = function(require_path) + return setmetatable({}, { + __index = function(_, key) + return require(require_path)[key] + end, + + __newindex = function(_, key, value) + require(require_path)[key] = value + end, + }) +end + +return lazy -- cgit v1.2.3