diff options
-rw-r--r-- | init.lua | 2 | ||||
-rw-r--r-- | lua/lvim/config/settings.lua | 1 | ||||
-rw-r--r-- | lua/lvim/core/alpha.lua | 9 | ||||
-rw-r--r-- | lua/lvim/core/autocmds.lua | 29 | ||||
-rw-r--r-- | lua/lvim/core/bufferline.lua | 2 | ||||
-rw-r--r-- | lua/lvim/core/cmp.lua | 49 | ||||
-rw-r--r-- | lua/lvim/core/comment.lua | 12 | ||||
-rw-r--r-- | lua/lvim/core/lir.lua | 21 | ||||
-rw-r--r-- | lua/lvim/core/telescope.lua | 45 | ||||
-rw-r--r-- | lua/lvim/core/theme.lua | 8 | ||||
-rw-r--r-- | lua/lvim/core/which-key.lua | 12 | ||||
-rw-r--r-- | lua/lvim/lsp/config.lua | 12 | ||||
-rw-r--r-- | lua/lvim/plugin-loader.lua | 4 | ||||
-rw-r--r-- | lua/lvim/plugins.lua | 36 | ||||
-rw-r--r-- | lua/lvim/utils.lua | 55 |
15 files changed, 198 insertions, 99 deletions
@@ -23,5 +23,3 @@ Log:debug "Starting LunarVim" local commands = require "lvim.core.commands" commands.load(commands.defaults) - -require("lvim.lsp").setup() diff --git a/lua/lvim/config/settings.lua b/lua/lvim/config/settings.lua index 0f3629bd..42281ca1 100644 --- a/lua/lvim/config/settings.lua +++ b/lua/lvim/config/settings.lua @@ -26,7 +26,6 @@ M.load_default_options = function() mouse = "a", -- allow the mouse to be used in neovim pumheight = 10, -- pop up menu height showmode = false, -- we don't need to see things like -- INSERT -- anymore - showtabline = 2, -- always show tabs smartcase = true, -- smart case splitbelow = true, -- force all horizontal splits to go below current window splitright = true, -- force all vertical splits to go to the right of current window diff --git a/lua/lvim/core/alpha.lua b/lua/lvim/core/alpha.lua index 3fded29f..19d7899a 100644 --- a/lua/lvim/core/alpha.lua +++ b/lua/lvim/core/alpha.lua @@ -1,17 +1,18 @@ local M = {} function M.config() - local lvim_dashboard = require "lvim.core.alpha.dashboard" - local lvim_startify = require "lvim.core.alpha.startify" + local utils = require "lvim.utils" + local lvim_dashboard = utils.lazy_set("lvim.core.alpha.dashboard", "get_sections") + local lvim_startify = utils.lazy_set("lvim.core.alpha.startify", "get_sections") lvim.builtin.alpha = { dashboard = { config = {}, - section = lvim_dashboard.get_sections(), + section = lvim_dashboard, opts = { autostart = true }, }, startify = { config = {}, - section = lvim_startify.get_sections(), + section = lvim_startify, opts = { autostart = true }, }, active = true, diff --git a/lua/lvim/core/autocmds.lua b/lua/lvim/core/autocmds.lua index 499f830e..bb080ced 100644 --- a/lua/lvim/core/autocmds.lua +++ b/lua/lvim/core/autocmds.lua @@ -121,6 +121,35 @@ function M.load_defaults() end, }, }, + { -- taken from AstroNvim + "BufEnter", + { + group = "_dir_opened", + once = true, + callback = function(args) + local bufname = vim.api.nvim_buf_get_name(args.buf) + if require("lvim.utils").is_directory(bufname) then + vim.api.nvim_del_augroup_by_name "_dir_opened" + vim.cmd "do User DirOpened" + vim.api.nvim_exec_autocmds("BufEnter", {}) + end + end, + }, + }, + { -- taken from AstroNvim + { "BufRead", "BufWinEnter", "BufNewFile" }, + { + group = "_file_opened", + once = true, + callback = function(args) + local buftype = vim.api.nvim_get_option_value("buftype", { buf = args.buf }) + if not (vim.fn.expand "%" == "" or buftype == "nofile") then + vim.cmd "do User FileOpened" + require("lvim.lsp").setup() + end + end, + }, + }, } M.define_autocmds(definitions) diff --git a/lua/lvim/core/bufferline.lua b/lua/lvim/core/bufferline.lua index 1344eb9a..abe16437 100644 --- a/lua/lvim/core/bufferline.lua +++ b/lua/lvim/core/bufferline.lua @@ -152,6 +152,8 @@ M.setup = function() return end + vim.opt.showtabline = 2 + bufferline.setup { options = lvim.builtin.bufferline.options, highlights = lvim.builtin.bufferline.highlights, diff --git a/lua/lvim/core/cmp.lua b/lua/lvim/core/cmp.lua index 142d548f..4d9e0de5 100644 --- a/lua/lvim/core/cmp.lua +++ b/lua/lvim/core/cmp.lua @@ -118,14 +118,15 @@ end M.methods.jumpable = jumpable M.config = function() - local status_cmp_ok, cmp = pcall(require, "cmp") + local status_cmp_ok, cmp_types = pcall(require, "cmp.types.cmp") if not status_cmp_ok then return end - local status_luasnip_ok, luasnip = pcall(require, "luasnip") - if not status_luasnip_ok then - return - end + + local cmp = require("lvim.utils").require_on_index "cmp" + local luasnip = require("lvim.utils").require_on_index "luasnip" + local cmp_window_config = require "cmp.config.window" + local cmp_mapping = require "cmp.config.mapping" lvim.builtin.cmp = { active = true, @@ -138,7 +139,7 @@ M.config = function() return lvim.builtin.cmp.active end, confirm_opts = { - behavior = cmp.ConfirmBehavior.Replace, + behavior = cmp_types.ConfirmBehavior.Replace, select = false, }, completion = { @@ -218,8 +219,8 @@ M.config = function() end, }, window = { - completion = cmp.config.window.bordered(), - documentation = cmp.config.window.bordered(), + completion = cmp_window_config.bordered(), + documentation = cmp_window_config.bordered(), }, sources = { { @@ -277,24 +278,24 @@ M.config = function() { name = "crates" }, { name = "tmux" }, }, - mapping = cmp.mapping.preset.insert { - ["<C-k>"] = cmp.mapping(cmp.mapping.select_prev_item(), { "i", "c" }), - ["<C-j>"] = cmp.mapping(cmp.mapping.select_next_item(), { "i", "c" }), - ["<Down>"] = cmp.mapping(cmp.mapping.select_next_item { behavior = cmp.SelectBehavior.Select }, { "i" }), - ["<Up>"] = cmp.mapping(cmp.mapping.select_prev_item { behavior = cmp.SelectBehavior.Select }, { "i" }), - ["<C-d>"] = cmp.mapping.scroll_docs(-4), - ["<C-f>"] = cmp.mapping.scroll_docs(4), - ["<C-y>"] = cmp.mapping { - i = cmp.mapping.confirm { behavior = cmp.ConfirmBehavior.Replace, select = false }, + mapping = cmp_mapping.preset.insert { + ["<C-k>"] = cmp_mapping(cmp_mapping.select_prev_item(), { "i", "c" }), + ["<C-j>"] = cmp_mapping(cmp_mapping.select_next_item(), { "i", "c" }), + ["<Down>"] = cmp_mapping(cmp_mapping.select_next_item { behavior = cmp_types.SelectBehavior.Select }, { "i" }), + ["<Up>"] = cmp_mapping(cmp_mapping.select_prev_item { behavior = cmp_types.SelectBehavior.Select }, { "i" }), + ["<C-d>"] = cmp_mapping.scroll_docs(-4), + ["<C-f>"] = cmp_mapping.scroll_docs(4), + ["<C-y>"] = cmp_mapping { + i = cmp_mapping.confirm { behavior = cmp_types.ConfirmBehavior.Replace, select = false }, c = function(fallback) if cmp.visible() then - cmp.confirm { behavior = cmp.ConfirmBehavior.Replace, select = false } + cmp.confirm { behavior = cmp_types.ConfirmBehavior.Replace, select = false } else fallback() end end, }, - ["<Tab>"] = cmp.mapping(function(fallback) + ["<Tab>"] = cmp_mapping(function(fallback) if cmp.visible() then cmp.select_next_item() elseif luasnip.expand_or_locally_jumpable() then @@ -308,7 +309,7 @@ M.config = function() fallback() end end, { "i", "s" }), - ["<S-Tab>"] = cmp.mapping(function(fallback) + ["<S-Tab>"] = cmp_mapping(function(fallback) if cmp.visible() then cmp.select_prev_item() elseif luasnip.jumpable(-1) then @@ -317,16 +318,16 @@ M.config = function() fallback() end end, { "i", "s" }), - ["<C-Space>"] = cmp.mapping.complete(), - ["<C-e>"] = cmp.mapping.abort(), - ["<CR>"] = cmp.mapping(function(fallback) + ["<C-Space>"] = cmp_mapping.complete(), + ["<C-e>"] = cmp_mapping.abort(), + ["<CR>"] = cmp_mapping(function(fallback) if cmp.visible() then local confirm_opts = vim.deepcopy(lvim.builtin.cmp.confirm_opts) -- avoid mutating the original opts below local is_insert_mode = function() return vim.api.nvim_get_mode().mode:sub(1, 1) == "i" end if is_insert_mode() then -- prevent overwriting brackets - confirm_opts.behavior = cmp.ConfirmBehavior.Insert + confirm_opts.behavior = cmp_types.ConfirmBehavior.Insert end if cmp.confirm(confirm_opts) then return -- success, exit early diff --git a/lua/lvim/core/comment.lua b/lua/lvim/core/comment.lua index 501d01b6..f07929c7 100644 --- a/lua/lvim/core/comment.lua +++ b/lua/lvim/core/comment.lua @@ -1,11 +1,6 @@ local M = {} function M.config() - local pre_hook - local loaded, ts_comment = pcall(require, "ts_context_commentstring.integrations.comment_nvim") - if loaded and ts_comment then - pre_hook = ts_comment.create_pre_hook() - end lvim.builtin.comment = { active = true, on_config_done = nil, @@ -66,7 +61,12 @@ function M.config() ---Pre-hook, called before commenting the line ---@type function|nil - pre_hook = pre_hook, + pre_hook = function(...) + local loaded, ts_comment = pcall(require, "ts_context_commentstring.integrations.comment_nvim") + if loaded and ts_comment then + return ts_comment.create_pre_hook()(...) + end + end, ---Post-hook, called after commenting is done ---@type function|nil diff --git a/lua/lvim/core/lir.lua b/lua/lvim/core/lir.lua index 9f915ed2..2c0e3c7a 100644 --- a/lua/lvim/core/lir.lua +++ b/lua/lvim/core/lir.lua @@ -1,22 +1,14 @@ local M = {} M.config = function() + local utils = require "lvim.utils" + local actions = utils.require_on_exported_call "lir.actions" + local clipboard_actions = utils.require_on_exported_call "lir.clipboard.actions" + lvim.builtin.lir = { active = true, on_config_done = nil, icon = "î—¿", - } - - local status_ok, _ = pcall(require, "lir") - if not status_ok then - return - end - - local actions = require "lir.actions" - local mark_actions = require "lir.mark.actions" - local clipboard_actions = require "lir.clipboard.actions" - - lvim.builtin.lir = vim.tbl_extend("force", lvim.builtin.lir, { show_hidden_files = false, ignore = {}, -- { ".DS_Store" "node_modules" } etc. devicons = { @@ -42,7 +34,7 @@ M.config = function() ["d"] = actions.delete, ["J"] = function() - mark_actions.toggle_mark() + require("lir.mark.actions").toggle_mark() vim.cmd "normal! j" end, ["c"] = clipboard_actions.copy, @@ -79,7 +71,7 @@ M.config = function() { noremap = true, silent = true } ) end, - }) + } end function M.icon_setup() @@ -118,6 +110,7 @@ function M.setup() end lir.setup(lvim.builtin.lir) + M.icon_setup() if lvim.builtin.lir.on_config_done then lvim.builtin.lir.on_config_done(lir) diff --git a/lua/lvim/core/telescope.lua b/lua/lvim/core/telescope.lua index a1b17e04..b8bd1b1c 100644 --- a/lua/lvim/core/telescope.lua +++ b/lua/lvim/core/telescope.lua @@ -7,21 +7,22 @@ local M = {} ---| "center" # retain the default telescope theme function M.config() - -- Define this minimal config so that it's available if telescope is not yet available. + local lazy_action = function(name) + return function(...) + if type(name) == "table" then + for _, n in ipairs(name) do + require("telescope.actions")[n](...) + end + return + end + require("telescope.actions")[name](...) + end + end lvim.builtin.telescope = { ---@usage disable telescope completely [not recommended] active = true, on_config_done = nil, - } - - local ok, actions = pcall(require, "telescope.actions") - if not ok then - return - end - lvim.builtin.telescope = { - active = true, - on_config_done = nil, theme = "dropdown", ---@type telescope_themes defaults = { prompt_prefix = lvim.icons.ui.Telescope .. " ", @@ -46,18 +47,18 @@ function M.config() ---@usage Mappings are fully customizable. Many familiar mapping patterns are setup as defaults. mappings = { i = { - ["<C-n>"] = actions.move_selection_next, - ["<C-p>"] = actions.move_selection_previous, - ["<C-c>"] = actions.close, - ["<C-j>"] = actions.cycle_history_next, - ["<C-k>"] = actions.cycle_history_prev, - ["<C-q>"] = actions.smart_send_to_qflist + actions.open_qflist, - ["<CR>"] = actions.select_default, + ["<C-n>"] = lazy_action "move_selection_next", + ["<C-p>"] = lazy_action "move_selection_previous", + ["<C-c>"] = lazy_action "close", + ["<C-j>"] = lazy_action "cycle_history_next", + ["<C-k>"] = lazy_action "cycle_history_prev", + ["<C-q>"] = lazy_action { "smart_send_to_qflist", "open_qflist" }, + ["<CR>"] = lazy_action "select_default", }, n = { - ["<C-n>"] = actions.move_selection_next, - ["<C-p>"] = actions.move_selection_previous, - ["<C-q>"] = actions.smart_send_to_qflist + actions.open_qflist, + ["<C-n>"] = lazy_action "move_selection_next", + ["<C-p>"] = lazy_action "move_selection_previous", + ["<C-q>"] = lazy_action { "smart_send_to_qflist", "open_qflist" }, }, }, file_ignore_patterns = {}, @@ -83,10 +84,10 @@ function M.config() initial_mode = "normal", mappings = { i = { - ["<C-d>"] = actions.delete_buffer, + ["<C-d>"] = lazy_action "delete_buffer", }, n = { - ["dd"] = actions.delete_buffer, + ["dd"] = lazy_action "delete_buffer", }, }, }, diff --git a/lua/lvim/core/theme.lua b/lua/lvim/core/theme.lua index 6bf67906..5a39f046 100644 --- a/lua/lvim/core/theme.lua +++ b/lua/lvim/core/theme.lua @@ -85,8 +85,12 @@ M.setup = function() vim.g.colors_name = lvim.colorscheme vim.cmd("colorscheme " .. lvim.colorscheme) - require("lvim.core.lualine").setup() - require("lvim.core.lir").icon_setup() + if package.loaded.lualine then + require("lvim.core.lualine").setup() + end + if package.loaded.lir then + require("lvim.core.lir").icon_setup() + end end return M diff --git a/lua/lvim/core/which-key.lua b/lua/lvim/core/which-key.lua index 8cedeabc..4f52c49b 100644 --- a/lua/lvim/core/which-key.lua +++ b/lua/lvim/core/which-key.lua @@ -205,20 +205,20 @@ M.config = function() a = { "<cmd>lua vim.lsp.buf.code_action()<cr>", "Code Action" }, d = { "<cmd>Telescope diagnostics bufnr=0 theme=get_ivy<cr>", "Buffer Diagnostics" }, w = { "<cmd>Telescope diagnostics<cr>", "Diagnostics" }, - f = { require("lvim.lsp.utils").format, "Format" }, + f = { "<cmd>lua require('lvim.lsp.utils').format()", "Format" }, i = { "<cmd>LspInfo<cr>", "Info" }, I = { "<cmd>Mason<cr>", "Mason Info" }, j = { - vim.diagnostic.goto_next, + "<cmd>lua vim.diagnostic.goto_next()", "Next Diagnostic", }, k = { - vim.diagnostic.goto_prev, + "<cmd>lua vim.diagnostic.goto_prev()", "Prev Diagnostic", }, - l = { vim.lsp.codelens.run, "CodeLens Action" }, - q = { vim.diagnostic.setloclist, "Quickfix" }, - r = { vim.lsp.buf.rename, "Rename" }, + l = { "<cmd>lua vim.lsp.codelens.run()", "CodeLens Action" }, + q = { "<cmd>lua vim.diagnostic.setloclist()", "Quickfix" }, + r = { "<cmd>lua vim.lsp.buf.rename()", "Rename" }, s = { "<cmd>Telescope lsp_document_symbols<cr>", "Document Symbols" }, S = { "<cmd>Telescope lsp_dynamic_workspace_symbols<cr>", diff --git a/lua/lvim/lsp/config.lua b/lua/lvim/lsp/config.lua index 6eecbf85..8f33f626 100644 --- a/lua/lvim/lsp/config.lua +++ b/lua/lvim/lsp/config.lua @@ -96,12 +96,12 @@ return { }, buffer_mappings = { normal_mode = { - ["K"] = { vim.lsp.buf.hover, "Show hover" }, - ["gd"] = { vim.lsp.buf.definition, "Goto Definition" }, - ["gD"] = { vim.lsp.buf.declaration, "Goto declaration" }, - ["gr"] = { vim.lsp.buf.references, "Goto references" }, - ["gI"] = { vim.lsp.buf.implementation, "Goto Implementation" }, - ["gs"] = { vim.lsp.buf.signature_help, "show signature help" }, + ["K"] = { "<cmd>lua vim.lsp.buf.hover()", "Show hover" }, + ["gd"] = { "<cmd>lua vim.lsp.buf.definition()", "Goto Definition" }, + ["gD"] = { "<cmd>lua vim.lsp.buf.declaration()", "Goto declaration" }, + ["gr"] = { "<cmd>lua vim.lsp.buf.references()", "Goto references" }, + ["gI"] = { "<cmd>lua vim.lsp.buf.implementation()", "Goto Implementation" }, + ["gs"] = { "<cmd>lua vim.lsp.buf.signature_help()", "show signature help" }, ["gl"] = { function() local config = lvim.lsp.diagnostics.float diff --git a/lua/lvim/plugin-loader.lua b/lua/lvim/plugin-loader.lua index c2118edf..31b2e6dd 100644 --- a/lua/lvim/plugin-loader.lua +++ b/lua/lvim/plugin-loader.lua @@ -39,6 +39,10 @@ function plugin_loader.init(opts) snapshot["lazy.nvim"].commit, } end + + vim.schedule(function() + require("lvim.lsp").setup() + end) end vim.opt.runtimepath:append(lazy_install_dir) diff --git a/lua/lvim/plugins.lua b/lua/lvim/plugins.lua index e1341398..47d40971 100644 --- a/lua/lvim/plugins.lua +++ b/lua/lvim/plugins.lua @@ -6,7 +6,7 @@ local core_plugins = { lazy = true, dependencies = { "mason-lspconfig.nvim", "nlsp-settings.nvim" }, }, - { "williamboman/mason-lspconfig.nvim", lazy = true }, + { "williamboman/mason-lspconfig.nvim", lazy = true, dependencies = "mason.nvim" }, { "tamago324/nlsp-settings.nvim", lazy = true }, { "jose-elias-alvarez/null-ls.nvim", lazy = true }, { @@ -14,17 +14,20 @@ local core_plugins = { config = function() require("lvim.core.mason").setup() end, + lazy = true, }, { "folke/tokyonight.nvim", + lazy = not vim.startswith(lvim.colorscheme, "tokyonight"), }, { "lunarvim/lunar.nvim", + lazy = lvim.colorscheme ~= "lunar", }, - { "Tastyep/structlog.nvim" }, + { "Tastyep/structlog.nvim", lazy = true }, - { "nvim-lua/popup.nvim" }, - { "nvim-lua/plenary.nvim" }, + { "nvim-lua/popup.nvim", lazy = true }, + { "nvim-lua/plenary.nvim", lazy = true }, -- Telescope { "nvim-telescope/telescope.nvim", @@ -113,21 +116,23 @@ local core_plugins = { vim.opt.rtp:prepend(path) -- treesitter needs to be before nvim's runtime in rtp require("lvim.core.treesitter").setup() end, + event = "User FileOpened", + dependencies = "nvim-ts-context-commentstring", }, { "JoosepAlviste/nvim-ts-context-commentstring", - event = "VeryLazy", + lazy = true, }, -- NvimTree { "kyazdani42/nvim-tree.lua", - -- event = "BufWinOpen", - -- cmd = "NvimTreeToggle", config = function() require("lvim.core.nvimtree").setup() end, enabled = lvim.builtin.nvimtree.active, + cmd = { "NvimTreeToggle", "NvimTreeOpen", "NvimTreeFocus" }, + event = "User DirOpened", }, -- Lir { @@ -136,13 +141,14 @@ local core_plugins = { require("lvim.core.lir").setup() end, enabled = lvim.builtin.lir.active, + event = "User DirOpened", }, { "lewis6991/gitsigns.nvim", config = function() require("lvim.core.gitsigns").setup() end, - event = "BufRead", + event = "User FileOpened", enabled = lvim.builtin.gitsigns.active, }, @@ -159,10 +165,10 @@ local core_plugins = { -- Comments { "numToStr/Comment.nvim", - event = "BufRead", config = function() require("lvim.core.comment").setup() end, + keys = { { "gc", mode = { "n", "v" } }, { "gb", mode = { "n", "v" } } }, enabled = lvim.builtin.comment.active, }, @@ -179,6 +185,7 @@ local core_plugins = { { "nvim-tree/nvim-web-devicons", enabled = lvim.use_icons, + lazy = true, }, -- Status Line and Bufferline @@ -189,6 +196,7 @@ local core_plugins = { config = function() require("lvim.core.lualine").setup() end, + event = "VimEnter", enabled = lvim.builtin.lualine.active, }, @@ -198,6 +206,7 @@ local core_plugins = { config = function() require("lvim.core.breadcrumbs").setup() end, + event = "User FileOpened", enabled = lvim.builtin.breadcrumbs.active, }, @@ -207,17 +216,18 @@ local core_plugins = { require("lvim.core.bufferline").setup() end, branch = "main", + event = "User FileOpened", enabled = lvim.builtin.bufferline.active, }, -- Debugging { "mfussenegger/nvim-dap", - -- event = "BufWinEnter", config = function() require("lvim.core.dap").setup() end, enabled = lvim.builtin.dap.active, + event = "User FileOpened", }, -- Debugger user interface @@ -227,6 +237,7 @@ local core_plugins = { require("lvim.core.dap").setup_ui() end, enabled = lvim.builtin.dap.active, + event = "User FileOpened", }, -- alpha @@ -260,7 +271,7 @@ local core_plugins = { config = function() require("lvim.core.illuminate").setup() end, - event = "VeryLazy", + event = "User FileOpened", enabled = lvim.builtin.illuminate.active, }, @@ -269,6 +280,7 @@ local core_plugins = { config = function() require("lvim.core.indentlines").setup() end, + event = "User FileOpened", enabled = lvim.builtin.indentlines.active, }, @@ -283,7 +295,7 @@ local core_plugins = { end end) end, - enabled = lvim.colorscheme == "onedarker", + lazy = lvim.colorscheme ~= "onedarker", }, { diff --git a/lua/lvim/utils.lua b/lua/lvim/utils.lua index 5e49906a..63831fe5 100644 --- a/lua/lvim/utils.lua +++ b/lua/lvim/utils.lua @@ -129,4 +129,59 @@ function M.fs_copy(source, destination) end end +-- code from <https://github.com/tjdevries/lazy-require.nvim/blob/bb626818ebc175b8c595846925fd96902b1ce02b/lua/lazy-require.lua#L25> +function M.require_on_index(require_path) + return setmetatable({}, { + __index = function(_, key) + return require(require_path)[key] + end, + + __newindex = function(_, key, value) + require(require_path)[key] = value + end, + }) +end + +-- code from <https://github.com/tjdevries/lazy-require.nvim/blob/bb626818ebc175b8c595846925fd96902b1ce02b/lua/lazy-require.lua#L25> +function M.require_on_exported_call(require_path) + return setmetatable({}, { + __index = function(_, k) + return function(...) + return require(require_path)[k](...) + end + end, + }) +end + +function M.lazy_set(require_path, fn_name) + local function poputale_table(table) + setmetatable(table, {}) + local source = require(require_path)[fn_name]() + for k, v in pairs(source) do + table[k] = v + end + end + return setmetatable({}, { + __index = function(me, index) + poputale_table(me) + return me[index] + end, + + __newindex = function(me, key, value) + poputale_table(me) + me[key] = value + end, + + __pairs = function(me) + poputale_table(me) + return pairs(me) + end, + + __ipairs = function(me) + poputale_table(me) + return pairs(me) + end, + }) +end + return M |