1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-02-15 23:39:27 +08:00

feat(flygrep): add ctrl-h to toggle hidden file

This commit is contained in:
Eric Wong 2025-02-03 00:37:55 +08:00
parent 8263e80286
commit 031d18a541
No known key found for this signature in database
GPG Key ID: 41BB7053E835C848
2 changed files with 14 additions and 0 deletions

View File

@ -96,6 +96,7 @@ require('flygrep').setup({
| `<C-v>` | open item in vertical split window |
| `<C-t>` | open item in new tabpage |
| `<C-p>` | toggle preview window |
| `<C-h>` | toggle display hidden files |
## Feedback

View File

@ -20,6 +20,7 @@ local grep_input = ''
local search_jobid = -1
local search_hi_id = -1
local fix_string = false
local include_hidden_file = false
-- all buffers
local result_bufid = -1
@ -48,6 +49,9 @@ local function build_grep_command()
for _, v in ipairs(conf.command.default_opts) do
table.insert(cmd, v)
end
if include_hidden_file then
table.insert(cmd, conf.command.hidden_opt)
end
if fix_string then
table.insert(cmd, conf.command.fixed_string_opt)
else
@ -143,6 +147,11 @@ local function build_prompt_title()
return t
end
local function toggle_hidden_file()
include_hidden_file = not include_hidden_file
vim.cmd('doautocmd TextChangedI')
end
local function toggle_fix_string()
fix_string = not fix_string
vim.cmd('doautocmd TextChangedI')
@ -416,6 +425,10 @@ local function open_win()
toggle_fix_string()
update_result_count()
end, { buffer = prompt_bufid })
vim.keymap.set('i', '<C-h>', function()
toggle_hidden_file()
update_result_count()
end, { buffer = prompt_bufid })
vim.keymap.set('i', '<C-p>', function()
toggle_preview_win()
end, { buffer = prompt_bufid })