Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add no_ignore option for fd #328

Merged
merged 3 commits into from
Nov 5, 2023
Merged
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ require("telescope").setup {
select_buffer = false,
hidden = { file_browser = false, folder_browser = false },
respect_gitignore = vim.fn.executable "fd" == 1
no_ignore = false,
follow_symlinks = false,
browse_files = require("telescope._extensions.file_browser.finders").browse_files,
browse_folders = require("telescope._extensions.file_browser.finders").browse_folders,
Expand Down
14 changes: 12 additions & 2 deletions doc/telescope-file-browser.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,9 @@ fb_picker.file_browser({opts}) *telescope-file-browser.picker.file_browser()*
List, create, delete, rename, or move files and folders of your cwd.
Notes
- Default keymaps in insert/normal mode:
- `<cr>` : Opens the currently selected file, or navigates to the
currently selected directory
- `<cr>` : Opens the currently selected file/directory, or creates
whatever is in the prompt
- `<s-cr>` : Create path in prompt
- `/`, `\` : (OS Path separator) When typing filepath, the path separator
will open a directory like `<cr>`.
- `<A-c>/c`: Create file/folder at current `path` (trailing path
Expand Down Expand Up @@ -133,6 +134,9 @@ fb_picker.file_browser({opts}) *telescope-file-browser.picker.file_browser()*
{respect_gitignore} (boolean) induces slow-down w/ plenary
finder (default: false, true if
`fd` available)
{no_ignore} (boolean) disable use of ignore files like
.gitignore/.ignore/.fdignore
(default: false, requires `fd`)
{follow_symlinks} (boolean) traverse symbolic links, i.e.
files and folders (default:
false, only works with `fd`)
Expand All @@ -150,6 +154,9 @@ fb_picker.file_browser({opts}) *telescope-file-browser.picker.file_browser()*
{quiet} (boolean) surpress any notification from
file_brower actions (default:
false)
{use_ui_input} (boolean) Use vim.ui.input() instead of
vim.fn.input() or
vim.fn.confirm() (default: true)
{dir_icon} (string) change the icon for a directory
(default: )
{dir_icon_hl} (string) change the highlight group of
Expand Down Expand Up @@ -468,6 +475,9 @@ fb_finders.finder({opts}) *telescope-file-browser.finders.finder()*
{respect_gitignore} (boolean) induces slow-down w/ plenary
finder (default: false, true if
`fd` available)
{no_ignore} (boolean) disable use of ignore files like
.gitignore/.ignore/.fdignore
(default: false, requires `fd`)
{follow_symlinks} (boolean) traverse symbolic links, i.e.
files and folders (default:
false, only works with `fd`)
Expand Down
5 changes: 5 additions & 0 deletions lua/telescope/_extensions/file_browser/finders.lua
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ local function fd_file_args(opts)
if not opts.respect_gitignore then
table.insert(args, "--no-ignore-vcs")
end
if opts.no_ignore then
table.insert(args, "--no-ignore")
end
if opts.follow_symlinks then
table.insert(args, "--follow")
end
Expand Down Expand Up @@ -170,6 +173,7 @@ end
---@field depth number: file tree depth to display (default: 1)
---@field hidden table|boolean: determines whether to show hidden files or not (default: `{ file_browser = false, folder_browser = false }`)
---@field respect_gitignore boolean: induces slow-down w/ plenary finder (default: false, true if `fd` available)
---@field no_ignore boolean: disable use of ignore files like .gitignore/.ignore/.fdignore (default: false, requires `fd`)
---@field follow_symlinks boolean: traverse symbolic links, i.e. files and folders (default: false, only works with `fd`)
---@field hide_parent_dir boolean: hide `../` in the file browser (default: false)
---@field dir_icon string: change the icon for a directory (default: )
Expand Down Expand Up @@ -199,6 +203,7 @@ fb_finders.finder = function(opts)
depth = vim.F.if_nil(opts.depth, 1), -- depth for file browser
auto_depth = vim.F.if_nil(opts.auto_depth, false), -- depth for file browser
respect_gitignore = vim.F.if_nil(opts.respect_gitignore, has_fd),
no_ignore = vim.F.if_nil(opts.no_ignore, false),
follow_symlinks = vim.F.if_nil(opts.follow_symlinks, false),
files = vim.F.if_nil(opts.files, true), -- file or folders mode
grouped = vim.F.if_nil(opts.grouped, false),
Expand Down
1 change: 1 addition & 0 deletions lua/telescope/_extensions/file_browser/picker.lua
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ local fb_picker = {}
---@field select_buffer boolean: select current buffer if possible; may imply `hidden=true` (default: false)
---@field hidden table|boolean: determines whether to show hidden files or not (default: `{ file_browser = false, folder_browser = false }`)
---@field respect_gitignore boolean: induces slow-down w/ plenary finder (default: false, true if `fd` available)
---@field no_ignore boolean: disable use of ignore files like .gitignore/.ignore/.fdignore (default: false, requires `fd`)
---@field follow_symlinks boolean: traverse symbolic links, i.e. files and folders (default: false, only works with `fd`)
---@field browse_files function: custom override for the file browser (default: |fb_finders.browse_files|)
---@field browse_folders function: custom override for the folder browser (default: |fb_finders.browse_folders|)
Expand Down
Loading