local want = require 'bugabinga.std.want' local bind = want { 'command_center' }(function(command_center) return function(map) map.visible = map.visible == nil or map.visible map.options = map.options or {} local options = vim.tbl_extend('keep', map.options, { silent = true, desc = map.description, }) if map.visible then local keybindings = {} if type(map.mode) == 'table' then for _, mode in ipairs(map.mode) do table.insert(keybindings, { mode, map.keys }) end else keybindings = { map.mode, map.keys } end command_center.add({ { description = map.description, category = map.category, cmd = map.command, keybindings = keybindings, }, }, command_center.mode.ADD_ONLY) end -- use neovim api to add keybind instead of command_center, because it has -- nicer defaults. vim.keymap.set(map.mode, map.keys, map.command, options) end end) return setmetatable({ MODE = { NORMAL = 'n', VISUAL = 'x', ALL = '', }, KEY = { SPACE = '', ENTER = '', ESCAPE = '', UP = '', DOWN = '', LEFT = '', RIGHT = '', ALT_H = '', ALT_J = '', ALT_K = '', ALT_L = '', ALT_SHIFT_H = '', ALT_SHIFT_J = '', ALT_SHIFT_K = '', ALT_SHIFT_L = '', }, COMMAND = { NOP = function() end, }, CATEGORY = { NAVIGATION = 'navigation', EDITING = 'editing', NOTIFY = 'notify', }, }, { __call = function(_, ...) return bind(...) end, })