diff --git a/bundle/quickfix.nvim/README.md b/bundle/quickfix.nvim/README.md index 193af765e..bf30d4dca 100644 --- a/bundle/quickfix.nvim/README.md +++ b/bundle/quickfix.nvim/README.md @@ -9,6 +9,7 @@ - [Install](#install) - [Key bindings in quickfix window](#key-bindings-in-quickfix-window) +- [Options](#options) - [Feedback](#feedback) @@ -31,11 +32,23 @@ Plug 'wsdjeg/quickfix.nvim' ## Key bindings in quickfix window -| Key bindings | description | -| ------------ | -------------------------------------------- | -| `dd` | remove item under cursor line in normal mode | -| `d` | remove selected items in visual mode | -| `c` | start filter mode | +| Key bindings | description | +| ------------ | ---------------------------------------------------------- | +| `dd` | remove item under cursor line in normal mode | +| `d` | remove selected items in visual mode | +| `c` | remove items which filename match input regex | +| `C` | remove items which filename not match input regex | +| `o` | remove items which error description match input regex | +| `O` | remove items which error description not match input regex | + +## Options + +- `g:quickfix_mapping_delete`: default is `dd` +- `g:quickfix_mapping_visual_delete`: default is `d` +- `g:quickfix_mapping_filter_filename`: default is `c` +- `g:quickfix_mapping_rfilter_filename`: default is `C` +- `g:quickfix_mapping_filter_text`: default is `o` +- `g:quickfix_mapping_rfilter_text`: default is `O` ## Feedback diff --git a/bundle/quickfix.nvim/lua/quickfix.lua b/bundle/quickfix.nvim/lua/quickfix.lua index b5ccecedb..80dfa497d 100644 --- a/bundle/quickfix.nvim/lua/quickfix.lua +++ b/bundle/quickfix.nvim/lua/quickfix.lua @@ -17,7 +17,7 @@ M.setup = function() pattern = 'qf', group = group, callback = function(ev) - vim.keymap.set('n', 'dd', function() + vim.keymap.set('n', vim.g.quickfix_mapping_delete or 'dd', function() local qflist = vim.fn.getqflist() local line = vim.fn.line('.') table.remove(qflist, line) @@ -41,7 +41,7 @@ M.setup = function() pattern = 'qf', group = group, callback = function(ev) - vim.keymap.set('v', 'd', function() + vim.keymap.set('v', vim.g.quickfix_mapping_visual_delete or 'd', function() local esc = vim.api.nvim_replace_termcodes('', true, false, true) vim.api.nvim_feedkeys(esc, 'x', false) local qflist = vim.fn.getqflist() @@ -60,7 +60,7 @@ M.setup = function() pattern = 'qf', group = group, callback = function(ev) - vim.keymap.set('n', 'c', function() + vim.keymap.set('n', vim.g.quickfix_mapping_filter_filename or 'c', function() local input_pattern = vim.fn.input('filter pattern:') -- vim.cmd('noautocmd normal! :') local re = vim.regex(input_pattern) @@ -74,6 +74,61 @@ M.setup = function() end, { buffer = ev.buf }) end, }) + + vim.api.nvim_create_autocmd({ 'FileType' }, { + pattern = 'qf', + group = group, + callback = function(ev) + vim.keymap.set('n', vim.g.quickfix_mapping_rfilter_filename or 'C', function() + local input_pattern = vim.fn.input('filter pattern:') + -- vim.cmd('noautocmd normal! :') + local re = vim.regex(input_pattern) + local qf = {} + for _, item in ipairs(vim.fn.getqflist()) do + if re:match_str(vim.fn.bufname(item.bufnr)) then + table.insert(qf, item) + end + end + vim.fn.setqflist(qf) + end, { buffer = ev.buf }) + end, + }) + vim.api.nvim_create_autocmd({ 'FileType' }, { + pattern = 'qf', + group = group, + callback = function(ev) + vim.keymap.set('n', vim.g.quickfix_mapping_filter_text or 'o', function() + local input_pattern = vim.fn.input('filter pattern:') + -- vim.cmd('noautocmd normal! :') + local re = vim.regex(input_pattern) + local qf = {} + for _, item in ipairs(vim.fn.getqflist()) do + if not re:match_str(item.text) then + table.insert(qf, item) + end + end + vim.fn.setqflist(qf) + end, { buffer = ev.buf }) + end, + }) + vim.api.nvim_create_autocmd({ 'FileType' }, { + pattern = 'qf', + group = group, + callback = function(ev) + vim.keymap.set('n', vim.g.quickfix_mapping_rfilter_text or 'O', function() + local input_pattern = vim.fn.input('filter pattern:') + -- vim.cmd('noautocmd normal! :') + local re = vim.regex(input_pattern) + local qf = {} + for _, item in ipairs(vim.fn.getqflist()) do + if re:match_str(item.text) then + table.insert(qf, item) + end + end + vim.fn.setqflist(qf) + end, { buffer = ev.buf }) + end, + }) end return M