autocommand: Fix unmap function to check if the keymap exists before deleting
This commit is contained in:
parent
faa55e3664
commit
432fabeed0
@ -1,5 +1,12 @@
|
||||
local markdown = vim.api.nvim_create_augroup("markdown", { clear = true })
|
||||
|
||||
local keyunmap = function(mode, binding)
|
||||
print(vim.inspect(vim.fn.maparg(binding, mode)))
|
||||
if vim.fn.maparg(binding, mode) ~= "" then
|
||||
vim.keymap.del(mode, binding)
|
||||
end
|
||||
end
|
||||
|
||||
-- Recognize .md as pandoc
|
||||
vim.api.nvim_create_autocmd({"BufEnter", "BufWinEnter"}, {
|
||||
pattern = {"*.md", },
|
||||
@ -34,8 +41,8 @@ vim.api.nvim_create_autocmd({"OptionSet"}, {
|
||||
vim.keymap.set("n", "<Leader>i", "mz[s1z=`z", {noremap = true, silent = true})
|
||||
vim.keymap.set("n", "à", "]s", {noremap = true, silent = true})
|
||||
else
|
||||
vim.keymap.del("n", "<Leader>i")
|
||||
vim.keymap.del("n", "à")
|
||||
keyunmap("n", "<Leader>i")
|
||||
keyunmap("n", "à")
|
||||
end
|
||||
end
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user