Skip to content

Commit

Permalink
fix(keymap): unmap keymaps if bqf is disabled (#42)
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinhwang91 committed Sep 26, 2021
1 parent 308b48c commit 84789c5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
16 changes: 16 additions & 0 deletions lua/bqf/keymap.lua
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,22 @@ function M.buf_map()
end
end

function M.buf_unmap()
local do_unmap = function(maparg)
if maparg.rhs:match([[lua require%('bqf%..*'%)]]) then
api.nvim_buf_del_keymap(0, maparg.mode, maparg.lhs)
end
end

for _, maparg in pairs(api.nvim_buf_get_keymap(0, 'n')) do
do_unmap(maparg)
end

for _, maparg in pairs(api.nvim_buf_get_keymap(0, 'x')) do
do_unmap(maparg)
end
end

setup()

return M
1 change: 1 addition & 0 deletions lua/bqf/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ function M.disable()
end
local qf_winid = api.nvim_get_current_win()
preview.close(qf_winid)
keymap.buf_unmap()
vim.b.bqf_enabled = false
cmd('au! Bqf')
cmd('sil! au! BqfPreview * <buffer>')
Expand Down

0 comments on commit 84789c5

Please sign in to comment.