1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-01-23 07:10:06 +08:00

Compare commits

...

7 Commits

Author SHA1 Message Date
Eric Wong
01d493a2b6 feat(quickfix): add undo key binding 2025-01-02 09:57:11 +08:00
Eric Wong
f3df26b6b3 docs(core): update doc about quickfix mappings 2025-01-02 09:16:11 +08:00
Eric Wong
14f7ef38a1 perf(quickfix): add option to set mappings 2025-01-02 09:09:28 +08:00
Eric Wong
d245875994 docs(core): update doc for core layer 2025-01-02 02:21:01 +08:00
Eric Wong
8ccdee05c1 docs(quickfix): update readme 2025-01-01 20:52:45 +08:00
Eric Wong
2b02440de8 ci(quickfix): detact quickfix.nvim 2025-01-01 20:43:55 +08:00
Eric Wong
805c03609f feat(quickfix): add quickfix.nvim 2025-01-01 20:34:26 +08:00
9 changed files with 314 additions and 1 deletions

View File

@ -567,6 +567,16 @@ EOT
_detact lua/spacevim/api/vim/window.lua
_detact autoload/SpaceVim/logger.vim
;;
quickfix.nvim)
git clone https://github.com/wsdjeg/quickfix.nvim.git detach/$1
cd detach/$1
_checkdir plugin
_checkdir lua
_detact_bundle quickfix.nvim lua/quickfix.lua
_detact_bundle quickfix.nvim plugin/quickfix.lua
_detact LICENSE
_detact_bundle quickfix.nvim README.md
;;
GitHub.vim)
git clone https://github.com/wsdjeg/GitHub.vim.git detach/$1
cd detach/$1

View File

@ -7,7 +7,7 @@ jobs:
strategy:
fail-fast: false
matrix:
detachPlugin: ["FlyGrep.vim", "dein-ui.vim", "vim-todo", "iedit.vim", "scrollbar.vim", "vim-chat", "vim-cheat", "xmake.vim", "GitHub.vim", "JavaUnit.vim", "git.vim", "cpicker.nvim", "SourceCounter.vim", "vim-zettelkasten", "format.nvim", "record-key.nvim"]
detachPlugin: ["FlyGrep.vim", "dein-ui.vim", "vim-todo", "iedit.vim", "scrollbar.vim", "vim-chat", "vim-cheat", "xmake.vim", "GitHub.vim", "JavaUnit.vim", "git.vim", "cpicker.nvim", "SourceCounter.vim", "vim-zettelkasten", "format.nvim", "record-key.nvim", "quickfix.nvim"]
runs-on: ubuntu-latest
steps:
- name: Checkout

View File

@ -21,6 +21,8 @@ scriptencoding utf-8
" 3. `enable_filetree_gitstatus`: enable/disable git status column in filetree.
" 4. `enable_filetree_filetypeicon`: enable/disable filetype icons in filetree.
" 5. `enable_netrw`: enable/disable netrw, disabled by default.
" 6. `enable_quickfix_key_bindings`: enable/disable quickfix.nvim, mappings
" for neovim quickfix window. This option is only for neovim.
"
" NOTE: the `enable_vimfiler_gitstatus` and `enable_filetree_gitstatus` option
" has been deprecated. Use layer option instead.
@ -152,6 +154,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 +241,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 +1220,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

View File

@ -0,0 +1,59 @@
# quickfix.nvim
> _quickfix.nvim_ is a plugin which provides default key bindings for quickfix window.
[![](https://spacevim.org/img/build-with-SpaceVim.svg)](https://spacevim.org)
[![GPLv3 License](https://img.spacevim.org/license-GPLv3-blue.svg)](LICENSE)
<!-- vim-markdown-toc GFM -->
- [Install](#install)
- [Key bindings in quickfix window](#key-bindings-in-quickfix-window)
- [Options](#options)
- [Feedback](#feedback)
<!-- vim-markdown-toc -->
## Install
1. Using `quickfix.nvim` in SpaceVim:
```toml
[[layers]]
name = 'core'
enable_quickfix_key_bindings = true
```
2. Using `quickfix.nvim` without SpaceVim:
```
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` | 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 |
| `u` | undo last change |
## 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`
- `g:quickfix_mapping_undo`: default is `u`
## Feedback
The development of this plugin is in [`SpaceVim/bundle/quickfix.nvim`](https://github.com/SpaceVim/SpaceVim/tree/master/bundle/quickfix.nvim) directory.
If you encounter any bugs or have suggestions, please file an issue in the [issue tracker](https://github.com/SpaceVim/SpaceVim/issues)

View File

@ -0,0 +1,169 @@
--=============================================================================
-- qf.lua
-- Copyright 2025 Eric Wong
-- Author: Eric Wong < wsdjeg@outlook.com >
-- URL: https://spacevim.org
-- License: GPLv3
--=============================================================================
local M = {}
local qf_historys = {}
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', vim.g.quickfix_mapping_delete or 'dd', function()
local qflist = vim.fn.getqflist()
local line = vim.fn.line('.')
if #qflist >= 1 then
table.insert(qf_historys, vim.deepcopy(qflist))
table.remove(qflist, line)
end
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', 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()
local from = vim.fn.getpos("'<")[2]
local to = vim.fn.getpos("'>")[2]
if from > to then
from, to = to, from
end
local qf = table_remove(qflist, from, to)
if #qf ~= #qflist and #qflist ~= 0 then
table.insert(qf_historys, qflist)
end
vim.fn.setqflist(qf)
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', 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)
local qflist = vim.fn.getqflist()
local qf = {}
for _, item in ipairs(qflist) do
if not re:match_str(vim.fn.bufname(item.bufnr)) then
table.insert(qf, item)
end
end
if #qf ~= #qflist and #qflist ~= 0 then
table.insert(qf_historys, qflist)
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_filename or 'C', function()
local input_pattern = vim.fn.input('filter pattern:')
local re = vim.regex(input_pattern)
local qf = {}
local qflist = vim.fn.getqflist()
for _, item in ipairs(qflist) do
if re:match_str(vim.fn.bufname(item.bufnr)) then
table.insert(qf, item)
end
end
if #qf ~= #qflist and #qflist ~= 0 then
table.insert(qf_historys, qflist)
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 = {}
local qflist = vim.fn.getqflist()
for _, item in ipairs(qflist) do
if not re:match_str(item.text) then
table.insert(qf, item)
end
end
if #qf ~= #qflist and #qflist ~= 0 then
table.insert(qf_historys, qflist)
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 = {}
local qflist = vim.fn.getqflist()
for _, item in ipairs(qflist) do
if re:match_str(item.text) then
table.insert(qf, item)
end
end
if #qf ~= #qflist and #qflist ~= 0 then
table.insert(qf_historys, qflist)
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_undo or 'u', function()
local qf = table.remove(qf_historys)
if qf then
vim.fn.setqflist(qf)
end
end, { buffer = ev.buf })
end,
})
end
return M

View 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()

View File

@ -2285,6 +2285,8 @@ OPTIONS
4. `enable_filetree_filetypeicon`: enable/disable filetype icons in
filetree.
5. `enable_netrw`: enable/disable netrw, disabled by default.
6. `enable_quickfix_key_bindings`: enable/disable quickfix.nvim, mappings
for neovim quickfix window. This option is only for neovim.
NOTE: the `enable_vimfiler_gitstatus` and `enable_filetree_gitstatus` option
has been deprecated. Use layer option instead.

View File

@ -27,10 +27,39 @@ nerdtree 或者 vimfiler默认为 vimfiler由 `filemanager` 选项控制
- `filetree_show_hidden`: 在文件树内显示隐藏的文件,默认是 false。
- `enable_smooth_scrolling`: 启用或者禁用平滑滚屏快捷键,默认已启用。
- `enable_filetree_gitstatus`: 在文件树内显示 Git 文件状态
- `enable_filetree_filetypeicon`: 在文件树内显示文件类型图标
- `enable_netrw`: 启用或者禁用 netrw
- `enable_quickfix_key_bindings`: 启用或者禁用 quickfix 窗口内常用快捷键
```toml
[[layers]]
name = 'core'
filetree_show_hidden = true
enable_smooth_scrolling = true
filetree_opened_icon = ''
filetree_closed_icon = ''
```
如果 `enable_quickfix_key_bindings` 设置为 `true`,那么可以在 quickfix 窗口内使用如下快捷键:
| 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 |
| `u` | undo last change |
也可以在启动函数里面使用如下变量修改默认的按键:
- `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`
- `g:quickfix_mapping_undo`: default is `u`

View File

@ -38,6 +38,7 @@ To use defx, please add following snippet into your configuration file.
- `enable_filetree_gitstatus`: enable/disable git status column in filetree.
- `enable_filetree_filetypeicon`: enable/disable filetype icons in filetree.
- `enable_netrw`: enable/disable netrw, disabled by default.
- `enable_quickfix_key_bindings`: enable/disable quickfix.nvim, mappings for neovim quickfix window. This option is only for neovim.
```toml
[[layers]]
@ -47,3 +48,27 @@ To use defx, please add following snippet into your configuration file.
filetree_opened_icon = ''
filetree_closed_icon = ''
```
If `enable_quickfix_key_bindings` is `true`, The following key bindings can be used in quickfix window,
and which also can be change in bootstrap function.
| 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 |
| `u` | undo last change |
Options to change these mappings:
- `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`
- `g:quickfix_mapping_undo`: default is `u`