From 9a3f6f061bf70d0b7082ca28718abc29e461314e Mon Sep 17 00:00:00 2001 From: Max Date: Sat, 6 Jan 2024 13:51:18 +0100 Subject: [PATCH] feat!: rewrite keybinding system --- lua/neorg/modules/core/keybinds/keybinds.lua | 365 +++++++++---------- lua/neorg/modules/core/keybinds/module.lua | 297 +++------------ 2 files changed, 237 insertions(+), 425 deletions(-) diff --git a/lua/neorg/modules/core/keybinds/keybinds.lua b/lua/neorg/modules/core/keybinds/keybinds.lua index 835620a29..70399d770 100644 --- a/lua/neorg/modules/core/keybinds/keybinds.lua +++ b/lua/neorg/modules/core/keybinds/keybinds.lua @@ -6,207 +6,202 @@ local module = modules.create("core.keybinds.keybinds") ---@class core.keybinds module.config.public = { keybind_presets = { - neorg = function(keybinds) - local leader = keybinds.leader - - -- Map all the below keybinds only when the "norg" mode is active - keybinds.map_event_to_mode("norg", { - n = { - -- Marks the task under the cursor as "undone" - -- ^mark Task as Undone - { - leader .. "tu", - "core.qol.todo_items.todo.task_undone", - opts = { desc = "Mark as Undone" }, - }, - - -- Marks the task under the cursor as "pending" - -- ^mark Task as Pending - { - leader .. "tp", - "core.qol.todo_items.todo.task_pending", - opts = { desc = "Mark as Pending" }, - }, - - -- Marks the task under the cursor as "done" - -- ^mark Task as Done - { leader .. "td", "core.qol.todo_items.todo.task_done", opts = { desc = "Mark as Done" } }, - - -- Marks the task under the cursor as "on_hold" - -- ^mark Task as on Hold - { - leader .. "th", - "core.qol.todo_items.todo.task_on_hold", - opts = { desc = "Mark as On Hold" }, - }, - - -- Marks the task under the cursor as "cancelled" - -- ^mark Task as Cancelled - { - leader .. "tc", - "core.qol.todo_items.todo.task_cancelled", - opts = { desc = "Mark as Cancelled" }, - }, - - -- Marks the task under the cursor as "recurring" - -- ^mark Task as Recurring - { - leader .. "tr", - "core.qol.todo_items.todo.task_recurring", - opts = { desc = "Mark as Recurring" }, - }, - - -- Marks the task under the cursor as "important" - -- ^mark Task as Important - { - leader .. "ti", - "core.qol.todo_items.todo.task_important", - opts = { desc = "Mark as Important" }, - }, + neorg = function(opts) + local leader = opts.leader + local default_bindings = { + -- Map all the below keybinds only when the "norg" mode is active + norg = { + n = { + -- Marks the task under the cursor as "undone" + -- ^mark Task as Undone + [leader .. "tu"] = { + + "core.qol.todo_items.todo.task_undone", + opts = { desc = "Mark as Undone" }, + }, + + -- Marks the task under the cursor as "pending" + -- ^mark Task as Pending + [leader .. "tp"] = { + + "core.qol.todo_items.todo.task_pending", + opts = { desc = "Mark as Pending" }, + }, + + -- Marks the task under the cursor as "done" + -- ^mark Task as Done + [leader .. "td"] = { "core.qol.todo_items.todo.task_done", opts = { desc = "Mark as Done" } }, + + -- Marks the task under the cursor as "on_hold" + -- ^mark Task as on Hold + [leader .. "th"] = { + + "core.qol.todo_items.todo.task_on_hold", + opts = { desc = "Mark as On Hold" }, + }, + + -- Marks the task under the cursor as "cancelled" + -- ^mark Task as Cancelled + [leader .. "tc"] = { + + "core.qol.todo_items.todo.task_cancelled", + opts = { desc = "Mark as Cancelled" }, + }, + + -- Marks the task under the cursor as "recurring" + -- ^mark Task as Recurring + [leader .. "tr"] = { + + "core.qol.todo_items.todo.task_recurring", + opts = { desc = "Mark as Recurring" }, + }, + + -- Marks the task under the cursor as "important" + -- ^mark Task as Important + [leader .. "ti"] = { + + "core.qol.todo_items.todo.task_important", + opts = { desc = "Mark as Important" }, + }, + + -- Marks the task under the cursor as "ambiguous" + -- ^mark Task as ambiguous + [leader .. "ta"] = { + + "core.qol.todo_items.todo.task_ambiguous", + opts = { desc = "Mark as Ambigous" }, + }, + + -- Switches the task under the cursor between a select few states + [""] = { "core.qol.todo_items.todo.task_cycle", opts = { desc = "Cycle Task" } }, + + -- Creates a new .norg file to take notes in + -- ^New Note + [leader .. "nn"] = { "core.dirman.new.note", opts = { desc = "Create New Note" } }, + + -- Hop to the destination of the link under the cursor + [""] = { "core.esupports.hop.hop-link", opts = { desc = "Jump to Link" } }, + ["gd"] = { "core.esupports.hop.hop-link", opts = { desc = "Jump to Link" } }, + ["gf"] = { "core.esupports.hop.hop-link", opts = { desc = "Jump to Link" } }, + ["gF"] = { "core.esupports.hop.hop-link", opts = { desc = "Jump to Link" } }, + + -- Same as ``, except opens the destination in a vertical split + [""] = { + + "core.esupports.hop.hop-link", + "vsplit", + opts = { desc = "Jump to Link (Vertical Split)" }, + }, + + [">."] = { "core.promo.promote", opts = { desc = "Promote Object (Non-Recursively)" } }, + ["<,"] = { "core.promo.demote", opts = { desc = "Demote Object (Non-Recursively)" } }, + + [">>"] = { "core.promo.promote", "nested", opts = { desc = "Promote Object (Recursively)" } }, + ["<<"] = { "core.promo.demote", "nested", opts = { desc = "Demote Object (Recursively)" } }, + + [leader .. "lt"] = { + + "core.pivot.toggle-list-type", + opts = { desc = "Toggle (Un)ordered List" }, + }, + [leader .. "li"] = { + + "core.pivot.invert-list-type", + opts = { desc = "Invert (Un)ordered List" }, + }, - -- Marks the task under the cursor as "ambiguous" - -- ^mark Task as ambiguous - { - leader .. "ta", - "core.qol.todo_items.todo.task_ambiguous", - opts = { desc = "Mark as Ambigous" }, + [leader .. "id"] = { "core.tempus.insert-date", opts = { desc = "Insert Date" } }, }, - -- Switches the task under the cursor between a select few states - { "", "core.qol.todo_items.todo.task_cycle", opts = { desc = "Cycle Task" } }, - - -- Creates a new .norg file to take notes in - -- ^New Note - { leader .. "nn", "core.dirman.new.note", opts = { desc = "Create New Note" } }, - - -- Hop to the destination of the link under the cursor - { "", "core.esupports.hop.hop-link", opts = { desc = "Jump to Link" } }, - { "gd", "core.esupports.hop.hop-link", opts = { desc = "Jump to Link" } }, - { "gf", "core.esupports.hop.hop-link", opts = { desc = "Jump to Link" } }, - { "gF", "core.esupports.hop.hop-link", opts = { desc = "Jump to Link" } }, - - -- Same as ``, except opens the destination in a vertical split - { - "", - "core.esupports.hop.hop-link", - "vsplit", - opts = { desc = "Jump to Link (Vertical Split)" }, + i = { + [""] = { "core.promo.promote", opts = { desc = "Promote Object (Recursively)" } }, + [""] = { "core.promo.demote", opts = { desc = "Demote Object (Recursively)" } }, + [""] = { "core.itero.next-iteration", "", opts = { desc = "Continue Object" } }, + [""] = { "core.tempus.insert-date-insert-mode", opts = { desc = "Insert Date" } }, }, - { ">.", "core.promo.promote", opts = { desc = "Promote Object (Non-Recursively)" } }, - { "<,", "core.promo.demote", opts = { desc = "Demote Object (Non-Recursively)" } }, - - { ">>", "core.promo.promote", "nested", opts = { desc = "Promote Object (Recursively)" } }, - { "<<", "core.promo.demote", "nested", opts = { desc = "Demote Object (Recursively)" } }, + -- TODO: Readd these + -- v = { + -- { ">>", ":Neorg keybind all core.promo.promote_range" }, + -- { "<<", ":Neorg keybind all core.promo.demote_range" }, + -- }, + }, - { - leader .. "lt", - "core.pivot.toggle-list-type", - opts = { desc = "Toggle (Un)ordered List" }, - }, - { - leader .. "li", - "core.pivot.invert-list-type", - opts = { desc = "Invert (Un)ordered List" }, + -- Map the below keys only when traverse-heading mode is active + ["traverse-heading"] = { + n = { + -- Move to the next heading in the document + j = { + "core.integrations.treesitter.next.heading", + opts = { desc = "Move to Next Heading" }, + }, + + -- Move to the previous heading in the document + k = { + "core.integrations.treesitter.previous.heading", + opts = { desc = "Move to Previous Heading" }, + }, }, - - { leader .. "id", "core.tempus.insert-date", opts = { desc = "Insert Date" } }, }, - i = { - { "", "core.promo.promote", opts = { desc = "Promote Object (Recursively)" } }, - { "", "core.promo.demote", opts = { desc = "Demote Object (Recursively)" } }, - { "", "core.itero.next-iteration", "", opts = { desc = "Continue Object" } }, - { "", "core.tempus.insert-date-insert-mode", opts = { desc = "Insert Date" } }, + -- Map the below keys only when traverse-link mode is active + ["traverse-link"] = { + n = { + -- Move to the next link in the document + j = { "core.integrations.treesitter.next.link", opts = { desc = "Move to Next Link" } }, + + -- Move to the previous link in the document + k = { + "core.integrations.treesitter.previous.link", + opts = { desc = "Move to Previous Link" }, + }, + }, }, - -- TODO: Readd these - -- v = { - -- { ">>", ":Neorg keybind all core.promo.promote_range" }, - -- { "<<", ":Neorg keybind all core.promo.demote_range" }, - -- }, - }, { - silent = true, - noremap = true, - }) - - -- Map the below keys only when traverse-heading mode is active - keybinds.map_event_to_mode("traverse-heading", { - n = { - -- Move to the next heading in the document - { - "j", - "core.integrations.treesitter.next.heading", - opts = { desc = "Move to Next Heading" }, - }, + -- Map the below keys on presenter mode + presenter = { + n = { + [""] = { "core.presenter.next_page", opts = { desc = "Next Page" } }, + l = { "core.presenter.next_page", opts = { desc = "Next Page" } }, + h = { "core.presenter.previous_page", opts = { desc = "Previous Page" } }, - -- Move to the previous heading in the document - { - "k", - "core.integrations.treesitter.previous.heading", - opts = { desc = "Move to Previous Heading" }, + -- Keys for closing the current display + q = { "core.presenter.close", opts = { desc = "Close Presentation" } }, + [""] = { "core.presenter.close", opts = { desc = "Close Presentation" } }, }, }, - }, { - silent = true, - noremap = true, - }) - - -- Map the below keys only when traverse-link mode is active - keybinds.map_event_to_mode("traverse-link", { - n = { - -- Move to the next link in the document - { "j", "core.integrations.treesitter.next.link", opts = { desc = "Move to Next Link" } }, - - -- Move to the previous link in the document - { - "k", - "core.integrations.treesitter.previous.link", - opts = { desc = "Move to Previous Link" }, - }, - }, - }, { - silent = true, - noremap = true, - }) - - -- Map the below keys on presenter mode - keybinds.map_event_to_mode("presenter", { - n = { - { "", "core.presenter.next_page", opts = { desc = "Next Page" } }, - { "l", "core.presenter.next_page", opts = { desc = "Next Page" } }, - { "h", "core.presenter.previous_page", opts = { desc = "Previous Page" } }, - - -- Keys for closing the current display - { "q", "core.presenter.close", opts = { desc = "Close Presentation" } }, - { "", "core.presenter.close", opts = { desc = "Close Presentation" } }, - }, - }, { - silent = true, - noremap = true, - nowait = true, - }) - - -- Apply the below keys to all modes - keybinds.map_to_mode("all", { - n = { - { leader .. "mn", "Neorg mode norg", opts = { desc = "Enter Norg Mode" } }, - { - leader .. "mh", - "Neorg mode traverse-heading", - opts = { desc = "Enter Heading Traversal Mode" }, - }, - { - leader .. "ml", - "Neorg mode traverse-link", - opts = { desc = "Enter Link Traversal Mode" }, + + -- Apply the below keys to all modes + all = { + n = { + [leader .. "mn"] = { + function() + vim.cmd("Neorg mode norg") + end, + opts = { desc = "Enter Norg Mode" }, + }, + [leader .. "mh"] = { + function() + vim.cmd("Neorg mode traverse-heading") + end, + opts = { desc = "Enter Heading Traversal Mode" }, + }, + [leader .. "ml"] = { + function() + vim.cmd("Neorg mode traverse-link") + end, + opts = { desc = "Enter Link Traversal Mode" }, + }, + ["gO"] = { + function() + vim.cmd("Neorg toc split") + end, + opts = { desc = "Open a Table of Contents" }, + }, }, - { "gO", "Neorg toc split", opts = { desc = "Open a Table of Contents" } }, }, - }, { - silent = true, - noremap = true, - }) + } + return vim.tbl_deep_extend("force", default_bindings, opts.overwrite) end, }, } diff --git a/lua/neorg/modules/core/keybinds/module.lua b/lua/neorg/modules/core/keybinds/module.lua index 93f0f6cc4..9957dcc76 100644 --- a/lua/neorg/modules/core/keybinds/module.lua +++ b/lua/neorg/modules/core/keybinds/module.lua @@ -72,14 +72,15 @@ end module.load = function() module.required["core.autocommands"].enable_autocommand("BufEnter") module.required["core.autocommands"].enable_autocommand("BufLeave") - - if module.config.public.hook then - neorg.callbacks.on_event( ---@diagnostic disable-line -- TODO: type error workaround - "core.keybinds.events.enable_keybinds", - function(_, keybinds) - module.config.public.hook(keybinds) - end - ) + if + module.config.public.default_keybinds + and module.imported["core.keybinds.keybinds"].config.public.keybind_presets[module.config.public.keybind_preset] + then + module.private.keybinds = + module.imported["core.keybinds.keybinds"].config.public.keybind_presets[module.config.public.keybind_preset]({ + leader = module.config.public.neorg_leader, + overwrite = module.config.public.overwrite, + }) end end @@ -92,9 +93,7 @@ module.config.public = { -- By default, this is the local leader key, which you must bind manually. neorg_leader = "", - -- Function to be invoked that allows the user to change their keybinds. - -- See the [section on setting up a keybind hook](#setting-up-a-keybind-hook) for more details. - hook = nil, + overwrite = {}, -- The keybind preset to use. -- @@ -170,242 +169,64 @@ module.public = { bind_all = function(buf, action, for_mode) local current_mode = for_mode or module.required["core.mode"].get_mode() - -- Keep track of the keys the user may want to bind - local bound_keys = {} - - -- Broadcast the enable_keybinds event to any user that might have registered a User Callback for it - local payload - - payload = { - - --- Maps a key to a specific Neorg mode - ---@param neorg_mode string #The Neorg mode to bind to - ---@param mode string #The Neovim mode to bind to, e.g. `n` or `i` etc. - ---@param key string #The lhs value from `:h vim.keymap.set` - ---@param command string|function #The rhs value from `:h vim.keymap.set` - ---@param opts table #The table value from `:h vim.keymap.set` - map = function(neorg_mode, mode, key, command, opts) - if neorg_mode ~= "all" and current_mode ~= neorg_mode then - return - end - - bound_keys[neorg_mode] = bound_keys[neorg_mode] or {} - bound_keys[neorg_mode][mode] = bound_keys[neorg_mode][mode] or {} - bound_keys[neorg_mode][mode][key] = bound_keys[neorg_mode][mode][key] or {} - - bound_keys[neorg_mode][mode][key] = { - command = command, - opts = opts, - } - end, - - --- Maps a key to a specific Neorg keybind. - -- `map()` binds to any rhs value, whilst `map_event()` is essentially a wrapper - -- for Neorg keybind `neorg_mode` `expr` - ---@param neorg_mode string #The Neorg mode to bind to - ---@param mode string #The Neovim mode to bind to, e.g. `n` or `i` etc. - ---@param key string #The lhs value from `:h vim.keymap.set` - ---@param expr string #The Neorg event to bind to (e.g. `core.dirman.new.note`) - ---@param opts table #The table value from `:h vim.keymap.set` - map_event = function(neorg_mode, mode, key, expr, opts) - payload.map(neorg_mode, mode, key, "Neorg keybind " .. neorg_mode .. " " .. expr .. "", opts) - end, - - --- Unmaps any keybind from any Neorg mode - ---@param neorg_mode string #The Neorg mode to remove the key from - ---@param mode string #The target Neovim mode - ---@param key string #The key itself to unmap - unmap = function(neorg_mode, mode, key) - if neorg_mode == "all" then - for _, norg_mode in ipairs(module.required["core.mode"].get_modes()) do - payload.unmap(norg_mode, mode, key) - end - end - - bound_keys[neorg_mode] = bound_keys[neorg_mode] or {} - bound_keys[neorg_mode][mode] = bound_keys[neorg_mode][mode] or {} - - bound_keys[neorg_mode][mode][key] = bound_keys[neorg_mode][mode][key] and nil - end, - - remap = function(neorg_mode, mode, key, new_rhs) - if neorg_mode ~= "all" and current_mode ~= neorg_mode then - return - end - - bound_keys[neorg_mode] = bound_keys[neorg_mode] or {} - bound_keys[neorg_mode][mode] = bound_keys[neorg_mode][mode] or {} - bound_keys[neorg_mode][mode][key] = bound_keys[neorg_mode][mode][key] or {} - - local opts = bound_keys[neorg_mode][mode][key].opts - - payload.map(neorg_mode, mode, key, new_rhs, opts) - end, - - remap_event = function(neorg_mode, mode, key, new_event) - if neorg_mode ~= "all" and current_mode ~= neorg_mode then - return - end - - bound_keys[neorg_mode] = bound_keys[neorg_mode] or {} - bound_keys[neorg_mode][mode] = bound_keys[neorg_mode][mode] or {} - bound_keys[neorg_mode][mode][key] = bound_keys[neorg_mode][mode][key] or {} - - local opts = bound_keys[neorg_mode][mode][key].opts - - payload.map( - neorg_mode, - mode, - key, - "Neorg keybind " .. neorg_mode .. " " .. new_event .. "", - opts - ) - end, - - remap_key = function(neorg_mode, mode, old_key, new_key) - if neorg_mode ~= "all" and current_mode ~= neorg_mode then - return - end - - bound_keys[neorg_mode] = bound_keys[neorg_mode] or {} - bound_keys[neorg_mode][mode] = bound_keys[neorg_mode][mode] or {} - bound_keys[neorg_mode][mode][old_key] = bound_keys[neorg_mode][mode][old_key] or {} - - local command = bound_keys[neorg_mode][mode][old_key].command - local opts = bound_keys[neorg_mode][mode][old_key].opts - - payload.unmap(neorg_mode, mode, old_key) - payload.map(neorg_mode, mode, new_key, command, opts) - end, - - --- An advanced wrapper around the map() function, maps several keys if the current neorg mode is the desired one - ---@param mode string #The neorg mode to bind the keys on - ---@param keys any #table { = { { "", "", custom_opts } } } - a table of keybinds ---@diagnostic disable-line -- TODO: type error workaround - ---@param opts any #table) - the same parameters that should be passed into vim.keymap.set('s opts parameter ---@diagnostic disable-line -- TODO: type error workaround - map_to_mode = function(mode, keys, opts) - -- If the keys table is empty then don't bother doing any parsing - if vim.tbl_isempty(keys) then - return - end - - -- If the current mode matches the desired mode then - if mode == "all" or (for_mode or module.required["core.mode"].get_mode()) == mode then - -- Loop through all the keybinds for a certain mode - for neovim_mode, keymaps in pairs(keys) do - -- Loop though all the keymaps in that mode - for _, keymap in ipairs(keymaps) do - -- Map the keybind and keep track of it using the map() function - payload.map(mode, neovim_mode, keymap[1], keymap[2], keymap[3] or opts) - end - end - end - end, - - --- An advanced wrapper around the map() function, maps several keys if the current neorg mode is the desired one - ---@param mode string #The neorg mode to bind the keys on - ---@param keys any #table { = { { "", "", custom_opts } } } - a table of keybinds ---@diagnostic disable-line -- TODO: type error workaround - ---@param opts any #table) - the same parameters that should be passed into vim.keymap.set('s opts parameter ---@diagnostic disable-line -- TODO: type error workaround - map_event_to_mode = function(mode, keys, opts) - -- If the keys table is empty then don't bother doing any parsing - if vim.tbl_isempty(keys) then - return - end - - -- If the current mode matches the desired mode then - if mode == "all" or (for_mode or module.required["core.mode"].get_mode()) == mode then - -- Loop through all the keybinds for a certain mode - for neovim_mode, keymaps in pairs(keys) do - -- Loop though all the keymaps in that mode - for _, keymap in ipairs(keymaps) do - -- Map the keybind and keep track of it using the map() function - payload.map(mode, neovim_mode, keymap[1], function() - vim.api.nvim_cmd({ - cmd = "Neorg", - args = vim.list_extend({ - "keybind", - mode, - }, vim.list_slice(keymap, 2)), - }, {}) - end, vim.tbl_deep_extend("force", opts, keymap.opts or {})) - end - end - end - end, - - -- Include the current Neorg mode and leader in the contents - mode = current_mode, - leader = module.config.public.neorg_leader, - } - - local function generate_default_functions(cb, ...) - local funcs = { ... } - - for _, func in ipairs(funcs) do - local name, to_exec = cb(func, payload[func]) - - payload[name] = to_exec - end - end - - generate_default_functions(function(name, func) - return name .. "d", function(...) - func("norg", ...) - end - end, "map", "map_event", "unmap", "remap", "remap_key", "remap_event") - if module.config.public.default_keybinds and module.imported["core.keybinds.keybinds"].config.public.keybind_presets[module.config.public.keybind_preset] then - module.imported["core.keybinds.keybinds"].config.public.keybind_presets[module.config.public.keybind_preset]( - payload - ) - end + for neorg_mode, neovim_modes in pairs(module.private.keybinds) do + if neorg_mode == "all" or neorg_mode == current_mode then + for mode, keys in pairs(neovim_modes) do + for key, data in pairs(keys) do + local ok, error = pcall(function() + local rhs + if type(data) == "function" then + rhs = data + elseif type(data) == "string" then + rhs = data + elseif type(data) == "table" then + rhs = data[1] + end + if type(rhs) == "string" and type(data) == "table" then + rhs = function() + vim.api.nvim_cmd({ + cmd = "Neorg", + args = vim.list_extend({ + "keybind", + neorg_mode, + }, vim.list_slice(data, 1)), + }, {}) + end + end + if action then + action(buf, mode, key, rhs, data.opts or {}) + else + local opts = data.opts or {} + opts.buffer = buf + + if opts.desc and not vim.startswith(opts.desc, "[neorg]") then + opts.desc = "[neorg] " .. opts.desc + end - for _, callback in pairs(module.private.requested_keys) do - callback(payload) - end + vim.keymap.set(mode, key, rhs, opts) + end + end) - -- Broadcast our event with the desired payload! - modules.broadcast_event( - modules.create_event(module, "core.keybinds.events.enable_keybinds", payload), - function() - for neorg_mode, neovim_modes in pairs(bound_keys) do - if neorg_mode == "all" or neorg_mode == current_mode then - for mode, keys in pairs(neovim_modes) do - for key, data in pairs(keys) do - local ok, error = pcall(function() - if action then - action(buf, mode, key, data.command, data.opts or {}) - else - local opts = data.opts or {} - opts.buffer = buf - - if opts.desc and not vim.startswith(opts.desc, "[neorg]") then - opts.desc = "[neorg] " .. opts.desc - end - - vim.keymap.set(mode, key, data.command, opts) - end - end) - - if not ok then - log.trace( - string.format( - "An error occurred when trying to bind key '%s' in mode '%s' in neorg mode '%s' - %s", - key, - mode, - current_mode, - error - ) + if not ok then + log.trace( + string.format( + "An error occurred when trying to bind key '%s' in mode '%s' in neorg mode '%s' - %s", + key, + mode, + current_mode, + error ) - end + ) end end end end end - ) + end end, --- Updates the list of known modes and keybinds for easy autocompletion. Invoked automatically during neorg_post_load(). @@ -418,14 +239,10 @@ module.public = { -- Update core.neorgcmd's internal tables module.required["core.neorgcmd"].add_commands_from_table(module.public.neorg_commands) end, - - request_keys = function(module_name, callback) - module.private.requested_keys[module_name] = callback - end, } module.private = { - requested_keys = {}, + keybinds = {}, } module.neorg_post_load = module.public.sync