diff --git a/lua/command_center/init.lua b/lua/command_center/init.lua index 28797e1..06711bc 100644 --- a/lua/command_center/init.lua +++ b/lua/command_center/init.lua @@ -21,6 +21,7 @@ local function process_commands(items, opts, set_callback, add_callback) item = utils.convert_item(item, opts) if not item then goto continue end + -- Register/unregister the keybindings if item.mode == constants.mode.SET or item.mode == constants.mode.ADD_SET then if type(set_callback) == "function" then diff --git a/lua/command_center/utils.lua b/lua/command_center/utils.lua index 3ce0291..baf61a1 100644 --- a/lua/command_center/utils.lua +++ b/lua/command_center/utils.lua @@ -74,7 +74,7 @@ local function validate_item(item) end return false end, "comment_center.mode" }, - category = { item.category, "string", true }, + cat = { item.cat, "string", true }, hydra_head_args = { item.hydra_head_args, "table", true }, }) @@ -208,13 +208,13 @@ function M.convert_keys(desc, cmd, keys, opts) return converted_key end - function M.set_converted_keys(keys) +function M.set_converted_keys(keys) for _, key in ipairs(keys) do vim.keymap.set(key.mode, key.lhs, key.rhs, key.opts) end end - function M.del_converted_keys(keys) +function M.del_converted_keys(keys) for _, key in ipairs(keys) do vim.keymap.del(key.mode, key.lhs, key.opts) end @@ -256,7 +256,6 @@ function M.format_keys(keys, opts) return formatted_keys end - ---Generate the string representation of keybindings ---@param keybindings table: properly formatted keybindings (by called format_keybindings) function M.get_keys_str(keybindings) @@ -302,10 +301,9 @@ function M.get_max_width(user_opts, length) return max_width + 6 -- Leave some margin at the end end - -- Filter items based on filter ---@return table: filtered item as a list -function M.filter_items(items,filter) +function M.filter_items(items, filter) local function filter_mode(item, mode) for _, key in ipairs(item) do diff --git a/lua/telescope/_extensions/command_center.lua b/lua/telescope/_extensions/command_center.lua index 8471623..883fb57 100644 --- a/lua/telescope/_extensions/command_center.lua +++ b/lua/telescope/_extensions/command_center.lua @@ -93,6 +93,7 @@ end local function run(filter) filter = filter or {} local filtered_items, cnt = utils.filter_items(M._items, filter) + local opts = vim.deepcopy(user_opts) -- Only display what the user specifies