diff --git a/README.md b/README.md index 8a68624..d225b7e 100644 --- a/README.md +++ b/README.md @@ -158,6 +158,8 @@ require('dressing').setup({ mappings = { n = { [""] = "Close", + -- You can also pass additional opts to vim.keymap.set(). + -- [""] = { "Close", nowait = true }, [""] = "Confirm", }, i = { diff --git a/doc/dressing.txt b/doc/dressing.txt index d5980cb..b5836da 100644 --- a/doc/dressing.txt +++ b/doc/dressing.txt @@ -48,6 +48,8 @@ Configure dressing.nvim by calling the setup() function. mappings = { n = { [""] = "Close", + -- You can also pass additional opts to vim.keymap.set(). + -- [""] = { "Close", nowait = true }, [""] = "Confirm", }, i = { diff --git a/lua/dressing/map_util.lua b/lua/dressing/map_util.lua index 61b1e3b..b7b6afa 100644 --- a/lua/dressing/map_util.lua +++ b/lua/dressing/map_util.lua @@ -8,7 +8,7 @@ end ---@param bufnr number ---@param mode string ----@param bindings table +---@param bindings table ---@param prefix string M.create_maps_to_plug = function(bufnr, mode, bindings, prefix) local maps @@ -17,6 +17,16 @@ M.create_maps_to_plug = function(bufnr, mode, bindings, prefix) end for lhs, rhs in pairs(bindings) do if rhs then + local opts = { buffer = bufnr, remap = true } + if type(rhs) == "table" then + for k, v in pairs(rhs) do + if type(k) == "string" then + opts[k] = v + elseif k == 1 then + rhs = v + end + end + end -- Prefix with unless this is a or :Cmd mapping if type(rhs) == "string" and not rhs:match("[<:]") then rhs = "" .. prefix .. rhs @@ -30,7 +40,7 @@ M.create_maps_to_plug = function(bufnr, mode, bindings, prefix) end end end - vim.keymap.set(mode, lhs, rhs, { buffer = bufnr, remap = true }) + vim.keymap.set(mode, lhs, rhs, opts) end end end