Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions lua/telescope/_extensions/egrepify.lua
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,22 @@ local egrepify = function(opts)
end
end

local hidden_opts = { "--hidden", "--no-ignore", "-u", "-uu", "-uuu" }
local ignore_opts = { "--no-hidden", "--ignore" }
if popts.vimgrep_arguments then
for i = #popts.vimgrep_arguments, 1, -1 do
if vim.tbl_contains(hidden_opts, popts.vimgrep_arguments[i]) then
popts.hidden = true
break
end
if vim.tbl_contains(ignore_opts, popts.vimgrep_arguments[i]) then
popts.hidden = false
break
end
end
popts.hidden = popts.hidden or false
end

egrep_picker(popts)
end

Expand Down
11 changes: 11 additions & 0 deletions lua/telescope/_extensions/egrepify/actions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,16 @@ function egrep_actions.toggle_permutations(prompt_bufnr)
current_picker:refresh()
end

--- Toggle the use of hidden files option in the picker
--- @param prompt_bufnr number: The prompt bufnr
function egrep_actions.toggle_hidden(prompt_bufnr)
local current_picker = action_state.get_current_picker(prompt_bufnr)
current_picker.hidden = not current_picker.hidden
local msg = current_picker.hidden and "Hidden files enabled" or "Hidden files disabled"
dismiss_notifications()
egrep_utils.notify("picker", { msg = msg, level = "INFO" })
current_picker:refresh()
end

egrep_actions = transform_mod(egrep_actions)
return egrep_actions
3 changes: 2 additions & 1 deletion lua/telescope/_extensions/egrepify/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ _TelescopeEgrepifyConfig = {
["<C-z>"] = egrep_actions.toggle_prefixes,
["<C-a>"] = egrep_actions.toggle_and,
["<C-r>"] = egrep_actions.toggle_permutations,
["<c-space>"] = actions.to_fuzzy_refine
["<C-h>"] = egrep_actions.toggle_hidden,
["<c-space>"] = actions.to_fuzzy_refine,
},
},
prefixes = {
Expand Down
10 changes: 10 additions & 0 deletions lua/telescope/_extensions/egrepify/picker.lua
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ end
---@field use_prefixes boolean use prefixes in prompt, toggleable with <C-z> (default: true)
---@field AND boolean search with fzf-like AND logic to ordered sub-tokens of prompt
---@field permutations boolean search permutations of sub-tokens of prompt, implies AND true
---@field hidden boolean search hidden files, toggleable with <C-h> (true if corresponding flags are set in `vimgrep_arguments`)
---@field prefixes table prefixes for `rg` input, see |telescope-egrepify.prefix|
---@field filename_hl string hl for title (default: `EgrepifyFile` w/ link to `Title`)
---@field title boolean filename as title, false to inline (default: true)
Expand Down Expand Up @@ -170,6 +171,13 @@ function Picker.picker(opts)
else -- matches everything in between sub-tokens and permutations
prompt = egrep_utils.permutations(tokens)
end
if current_picker and current_picker.hidden then
prompt_args[#prompt_args + 1] = "--no-ignore"
prompt_args[#prompt_args + 1] = "--hidden"
else
prompt_args[#prompt_args + 1] = "--ignore"
prompt_args[#prompt_args + 1] = "--no-hidden"
end

return flatten { args, prompt_args, "--", prompt, search_list }
end, egrep_entry_maker(opts), opts.max_results, opts.cwd)
Expand All @@ -196,6 +204,7 @@ function Picker.picker(opts)
cached_opts.use_prefixes = picker.use_prefixes
cached_opts.AND = picker.AND
cached_opts.permutations = picker.permutations
cached_opts.hidden = picker.hidden
end
end,
}
Expand All @@ -209,6 +218,7 @@ function Picker.picker(opts)
picker.AND = vim.F.if_nil(opts.AND, egrep_conf.AND)
-- matches everything in between sub-tokens and permutations
picker.permutations = vim.F.if_nil(opts.permutations, egrep_conf.permutations)
picker.hidden = vim.F.if_nil(opts.hidden, egrep_conf.hidden)

if picker.permutations then
picker.AND = true
Expand Down