mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-01-23 07:20:04 +08:00
perf(quickfix): add option to set mappings
This commit is contained in:
parent
d245875994
commit
14f7ef38a1
@ -9,6 +9,7 @@
|
||||
|
||||
- [Install](#install)
|
||||
- [Key bindings in quickfix window](#key-bindings-in-quickfix-window)
|
||||
- [Options](#options)
|
||||
- [Feedback](#feedback)
|
||||
|
||||
<!-- vim-markdown-toc -->
|
||||
@ -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
|
||||
|
||||
|
@ -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('<esc>', 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
|
||||
|
Loading…
Reference in New Issue
Block a user