mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-01-23 07:10:06 +08:00
feat(quickfix): add quickfix.nvim
This commit is contained in:
parent
a0fc3ad290
commit
805c03609f
@ -152,6 +152,7 @@ endif
|
||||
|
||||
let s:enable_smooth_scrolling = 1
|
||||
let s:enable_netrw = 0
|
||||
let s:enable_quickfix_key_bindings = 0
|
||||
|
||||
let g:_spacevim_enable_filetree_gitstatus = 0
|
||||
let g:_spacevim_enable_filetree_filetypeicon = 0
|
||||
@ -238,6 +239,10 @@ function! SpaceVim#layers#core#plugins() abort
|
||||
\}])
|
||||
call add(plugins, [g:_spacevim_root_dir . 'bundle/vim-grepper' , { 'on_cmd' : 'Grepper',
|
||||
\ 'loadconf' : 1} ])
|
||||
|
||||
if s:enable_quickfix_key_bindings
|
||||
call add(plugins, [g:_spacevim_root_dir . 'bundle/quickfix.nvim' , { 'merged' : 0} ])
|
||||
endif
|
||||
return plugins
|
||||
endfunction
|
||||
|
||||
@ -1213,6 +1218,9 @@ function! SpaceVim#layers#core#set_variable(var) abort
|
||||
let s:enable_netrw = get(a:var,
|
||||
\ 'enable_netrw',
|
||||
\ 0)
|
||||
let s:enable_quickfix_key_bindings = get(a:var,
|
||||
\ 'enable_quickfix_key_bindings',
|
||||
\ s:enable_quickfix_key_bindings)
|
||||
endfunction
|
||||
|
||||
function! s:defx_find_current_file() abort
|
||||
|
0
bundle/quickfix.nvim/README.md
Normal file
0
bundle/quickfix.nvim/README.md
Normal file
79
bundle/quickfix.nvim/lua/quickfix.lua
Normal file
79
bundle/quickfix.nvim/lua/quickfix.lua
Normal file
@ -0,0 +1,79 @@
|
||||
--=============================================================================
|
||||
-- qf.lua
|
||||
-- Copyright 2025 Eric Wong
|
||||
-- Author: Eric Wong < wsdjeg@outlook.com >
|
||||
-- URL: https://spacevim.org
|
||||
-- License: GPLv3
|
||||
--=============================================================================
|
||||
|
||||
local M = {}
|
||||
|
||||
M.setup = function()
|
||||
local group = vim.api.nvim_create_augroup('quickfix_mapping', {
|
||||
clear = true,
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd({ 'FileType' }, {
|
||||
pattern = 'qf',
|
||||
group = group,
|
||||
callback = function(ev)
|
||||
vim.keymap.set('n', 'dd', function()
|
||||
local qflist = vim.fn.getqflist()
|
||||
local line = vim.fn.line('.')
|
||||
table.remove(qflist, line)
|
||||
vim.fn.setqflist(qflist)
|
||||
vim.cmd(tostring(line))
|
||||
end, { buffer = ev.buf })
|
||||
end,
|
||||
})
|
||||
|
||||
local function table_remove(t, from, to)
|
||||
local rst = {}
|
||||
for i = 1, #t, 1 do
|
||||
if i < from or i > to then
|
||||
rst[#rst + 1] = t[i]
|
||||
end
|
||||
end
|
||||
return rst
|
||||
end
|
||||
|
||||
vim.api.nvim_create_autocmd({ 'FileType' }, {
|
||||
pattern = 'qf',
|
||||
group = group,
|
||||
callback = function(ev)
|
||||
vim.keymap.set('v', '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()
|
||||
local from = vim.fn.getpos("'<")[2]
|
||||
local to = vim.fn.getpos("'>")[2]
|
||||
if from > to then
|
||||
from, to = to, from
|
||||
end
|
||||
qflist = table_remove(qflist, from, to)
|
||||
vim.fn.setqflist(qflist)
|
||||
vim.cmd(tostring(from))
|
||||
end, { buffer = ev.buf })
|
||||
end,
|
||||
})
|
||||
vim.api.nvim_create_autocmd({ 'FileType' }, {
|
||||
pattern = 'qf',
|
||||
group = group,
|
||||
callback = function(ev)
|
||||
vim.keymap.set('n', '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 not re:match_str(vim.fn.bufname(item.bufnr)) then
|
||||
table.insert(qf, item)
|
||||
end
|
||||
end
|
||||
vim.fn.setqflist(qf)
|
||||
end, { buffer = ev.buf })
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
return M
|
9
bundle/quickfix.nvim/plugin/quickfix.lua
Normal file
9
bundle/quickfix.nvim/plugin/quickfix.lua
Normal file
@ -0,0 +1,9 @@
|
||||
--=============================================================================
|
||||
-- quickfix.lua
|
||||
-- Copyright 2025 Eric Wong
|
||||
-- Author: Eric Wong < wsdjeg@outlook.com >
|
||||
-- URL: https://spacevim.org
|
||||
-- License: GPLv3
|
||||
--=============================================================================
|
||||
|
||||
require('quickfix').setup()
|
Loading…
Reference in New Issue
Block a user