diff --git a/lua/incr/init.lua b/lua/incr/init.lua index a583794..16e0f0e 100644 --- a/lua/incr/init.lua +++ b/lua/incr/init.lua @@ -47,11 +47,20 @@ local function select_node(node) vim.api.nvim_win_set_cursor(0, { end_row_pos, end_col_pos > 0 and end_col_pos - 1 or 0 }) end +local function in_cmd_buf(key) + local buftype = vim.api.nvim_get_option_value('buftype', {}) + if buftype ~= 'quickfix' and + vim.fn.getcmdwintype() == '' then return false end + vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes(key, true, false, true), 'n', false) + return true +end + M.setup = function(config) local incr_key = config.incr_key and config.incr_key or '' local decr_key = config.decr_key and config.decr_key or '' vim.keymap.set({ 'n' }, incr_key, function() + if in_cmd_buf(incr_key) then return end _G.selected_nodes = {} local current_node = get_node_at_cursor() @@ -121,6 +130,7 @@ M.setup = function(config) end, { desc = 'Increment selection' }) vim.keymap.set('x', decr_key, function() + if in_cmd_buf(decr_key) then return end if #_G.selected_nodes > 1 then table.remove(_G.selected_nodes) local current_node = _G.selected_nodes[#_G.selected_nodes]