feat: fixed & added mappings & users can now add their custom "mode_opt"

This commit is contained in:
Leon Heidelbach 2022-05-12 22:13:00 +02:00 committed by siduck
parent 63651e90e6
commit c7a4d4e337
2 changed files with 23 additions and 6 deletions

View File

@ -224,11 +224,11 @@ M.telescope = {
-- find
["<leader>ff"] = { "<cmd> Telescope find_files <CR>", " find files" },
["<leader>fa"] = { "<cmd> Telescope find_files follow=true no_ignore=true hidden=true <CR>", " find all" },
["<leader>fw"] = { "<cmd> Telescope live_grep <CR>", "live grep" },
["<leader>fw"] = { "<cmd> Telescope live_grep <CR>", " live grep" },
["<leader>fb"] = { "<cmd> Telescope buffers <CR>", " find buffers" },
["<leader>fh"] = { "<cmd> Telescope help_tags <CR>", " help page" },
["<leader>fo"] = { "<cmd> Telescope oldfiles <CR>", "find oldfiles" },
["<leader>tk"] = { "<cmd> Telescope keys <CR>", " show keys" },
["<leader>fo"] = { "<cmd> Telescope oldfiles <CR>", " find oldfiles" },
["<leader>tk"] = { "<cmd> Telescope keymaps <CR>", " show keys" },
-- git
["<leader>cm"] = { "<cmd> Telescope git_commits <CR>", " git commits" },
@ -285,4 +285,20 @@ M.nvterm = {
},
}
M.whichkey = {
n = {
["<leader>wK"] = {
function()
vim.cmd("WhichKey")
end, " which-key all keymaps",
},
["<leader>wk"] = {
function()
local input = vim.fn.input("WhichKey: ")
vim.cmd("WhichKey " .. input)
end, " which-key query lookup",
},
}
}
return M

View File

@ -61,9 +61,10 @@ local mappings = nvchad.load_config().mappings
-- register mappings
for mode, opt in pairs(options.mode_opts) do
for key, _ in pairs(mappings) do
if mappings[key][mode] then
wk.register(mappings[key][mode], opt)
for _, value in pairs(mappings) do
if value[mode] then
local mode_opts = value["mode_opts"] and vim.tbl_deep_extend("force", opt, value["mode_opts"]) or opt
wk.register(value[mode], mode_opts)
end
end
end