Skip to content

Commit

Permalink
Merge pull request #112 from Cassin01/Fixes#105
Browse files Browse the repository at this point in the history
Fixes#105
Add setup options for builtin keymaps.
  • Loading branch information
Cassin01 committed Mar 9, 2024
2 parents 50a2b84 + 41e6df8 commit 999c0db
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lua/wf/builtin/which_key.lua
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ end

local function leader()
local ml = vim.g["mapleader"]
if ml then
if ml ~= nil then
if ml == " " then
return "<Space>"
else
Expand Down
4 changes: 2 additions & 2 deletions lua/wf/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,8 @@ local function objs_setup(fuzzy_obj, which_obj, output_obj, caller_obj, choices_
end

local which_key_list_operator = {
escape = "<C-C>",
toggle = "<C-T>",
escape = vim.g[full_name .. "#builtin_keymaps#escape"] or "<C-C>",
toggle = vim.g[full_name .. "#builtin_keymaps#toggle"] or "<C-T>",
}
for _, o in ipairs(objs) do
bmap(o.buf, "n", "<esc>", del, "quit")
Expand Down
13 changes: 10 additions & 3 deletions lua/wf/setup/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,8 @@ end
---@param opts? WFConfig
local function setup(opts)
opts = opts or { theme = "default" }
opts.highlight = opts["highlight"] or themes[opts["theme"] or "default"].highlight
local keymaps = opts["keymaps"] or {}

opts.highlight = opts["highlight"] or themes[opts["theme"] or "default"].highlight
for k, v in pairs(opts.highlight) do
if type(v) == "string" then
vim.api.nvim_set_hl(0, k, { default = true, link = v })
Expand All @@ -171,7 +170,15 @@ local function setup(opts)
end
vim.g[full_name .. "#theme"] = opts.theme

-- setup_keymap(keymaps)
opts["builtin_keymaps"] = opts["builtin_keymaps"]
or {
escape = "<C-C>", -- Accept null
toggle = "<C-T>", -- Not Accept null
}
opts["builtin_keymaps"]["escape"] = opts["builtin_keymaps"]["escape"] or "<C-C>"
opts["builtin_keymaps"]["toggle"] = opts["builtin_keymaps"]["toggle"] or "<C-T>"
vim.g[full_name .. "#builtin_keymaps#escape"] = opts["builtin_keymaps"]["escape"]
vim.g[full_name .. "#builtin_keymaps#toggle"] = opts["builtin_keymaps"]["toggle"]
end

return { setup = setup }

0 comments on commit 999c0db

Please sign in to comment.