Skip to content

Commit

Permalink
feat(action): add toggle_respect_gitignore action
Browse files Browse the repository at this point in the history
closes #291
  • Loading branch information
jamestrew committed Jul 28, 2023
1 parent 721f716 commit e75f0d5
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
14 changes: 14 additions & 0 deletions lua/telescope/_extensions/file_browser/actions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,20 @@ fb_actions.toggle_hidden = function(prompt_bufnr)
current_picker:refresh(finder, { reset_prompt = true, multi = current_picker._multi })
end


--- Toggle respect_gitignore for |telescope-file-browser.picker.file_browser|.
---@param prompt_bufnr number: The prompt bufnr
fb_actions.toggle_respect_gitignore = function(prompt_bufnr)
local current_picker = action_state.get_current_picker(prompt_bufnr)
local finder = current_picker.finder

if type(finder.respect_gitignore) == "boolean" then
finder.respect_gitignore = not finder.respect_gitignore
end
current_picker:refresh(finder, { reset_prompt = true, multi = current_picker._multi })
end


--- Opens the file or folder with the default application.<br>
--- - Notes:
--- - map fb_actions.open + fb_actions.close if you want to close the picker post-action
Expand Down
12 changes: 7 additions & 5 deletions lua/telescope/_extensions/file_browser/finders.lua
Original file line number Diff line number Diff line change
Expand Up @@ -42,23 +42,25 @@ local function fd_file_args(opts)
"--base-directory=" .. opts.path,
"--absolute-path",
"--path-separator=" .. os_sep,
"--type",
"file"
}
if opts.add_dirs == false then
if opts.add_dirs then
table.insert(args, "--type")
table.insert(args, "file")
table.insert(args, "directory")
end
if type(opts.depth) == "number" then
table.insert(args, "--maxdepth")
table.insert(args, opts.depth)
end
else
args = { "-t", "d", "-a" }
args = { "--t", "directory", "--absolute-path" }
end

if hidden_opts(opts) then
table.insert(args, "-H")
table.insert(args, "--hidden")
end
if opts.respect_gitignore == false then
if not opts.respect_gitignore then
table.insert(args, "--no-ignore-vcs")
end
return args
Expand Down

0 comments on commit e75f0d5

Please sign in to comment.