Add silent option to a lot of keymaps to hide command display.

This commit is contained in:
Martin Larsson 2024-10-30 17:47:29 +01:00
parent 23ed2e9964
commit 8263b02c70
6 changed files with 26 additions and 7 deletions

View file

@ -33,7 +33,7 @@ return {
},
})
require("utils").add_keymaps({
local keymaps = {
n = {
["<Leader>ci"] = { cmd = "<cmd>CodeCompanion<cr>" },
["<Leader>cc"] = { cmd = "<cmd>CodeCompanionChat toggle<cr>" },
@ -46,7 +46,10 @@ return {
["<Leader>cf"] = { cmd = "<cmd>CodeCompanion /fix<cr>" },
["<Leader>ct"] = { cmd = "<cmd>CodeCompanion /tests<cr>" },
}
})
}
local utils = require("utils")
utils.add_opts_to_all_mappings(keymaps, { silent = true })
utils.add_keymaps(keymaps)
vim.cmd([[cab cc CodeCompanion]])
end

View file

@ -17,7 +17,8 @@ return {
require("utils").add_keymaps({
v = {
["<leader>cs"] = {
cmd = ":CodeSnap<CR>"
cmd = ":CodeSnap<CR>",
opts = { silent = true },
},
}
})

View file

@ -28,7 +28,7 @@ return {
}
})
require("utils").add_keymaps({
local keymaps = {
n = {
["[d"] = {
cmd = ":Lspsaga diagnostic_jump_prev<CR>"
@ -58,6 +58,9 @@ return {
cmd = ":Lspsaga incoming_calls<CR>"
},
}
})
}
local utils = require("utils")
utils.add_opts_to_all_mappings(keymaps, { silent = true })
utils.add_keymaps(keymaps)
end,
}

View file

@ -122,7 +122,8 @@ return {
keymaps.n["<leader>" .. command.keys] = {
cmd = function()
toggle_trouble_mode(command.mode)
end
end,
opts = { silent = true }
}
end
utils.add_keymaps(keymaps)

View file

@ -5,7 +5,7 @@ return {
config = function()
require("utils").add_keymaps({
n = {
["<leader>ud"] = { cmd = ":UndotreeToggle<CR>" }
["<leader>ud"] = { cmd = ":UndotreeToggle<CR>", opts = { silent = true } }
}
})
end

View file

@ -25,6 +25,17 @@ function M.broadcast_event(event_name)
vim.api.nvim_command("doautocmd <nomodeline> User " .. event_name)
end
function M.add_opts_to_all_mappings(mappings, opts)
assert(opts and mappings)
for _, modes in pairs(mappings) do
for _, mapping in pairs(modes) do
local existing_opts = mapping.opts or {}
mapping.opts = vim.tbl_extend("force", existing_opts, opts)
end
end
end
function M.add_keymaps(maps)
assert(maps)