diff --git a/doc/telescope.txt b/doc/telescope.txt index 8d90dc2..7fc66e2 100644 --- a/doc/telescope.txt +++ b/doc/telescope.txt @@ -878,22 +878,24 @@ builtin.find_files({opts}) *telescope.builtin.find_files()* {opts} (table) options to pass to the picker Options: ~ - {cwd} (string) root dir to search from (default: cwd, - use utils.buffer_dir() to search - relative to open buffer) - {find_command} (table) command line arguments for `find_files` - to use for the search, overrides - default: config - {follow} (boolean) if true, follows symlinks (i.e. uses - `-L` flag for the `find` command) - {hidden} (boolean) determines whether to show hidden files - or not (default: false) - {no_ignore} (boolean) show files ignored by .gitignore, - .ignore, etc. (default: false) - {no_ignore_parent} (boolean) show files ignored by .gitignore, - .ignore, etc. in parent dirs. (default: - false) - {search_dirs} (table) directory/directories to search in + {cwd} (string) root dir to search from (default: + cwd, use utils.buffer_dir() to + search relative to open buffer) + {find_command} (function|table) cmd to use for the search. Can be + a fn(opts) -> tbl (default: + autodetect) + {follow} (boolean) if true, follows symlinks (i.e. + uses `-L` flag for the `find` + command) + {hidden} (boolean) determines whether to show hidden + files or not (default: false) + {no_ignore} (boolean) show files ignored by .gitignore, + .ignore, etc. (default: false) + {no_ignore_parent} (boolean) show files ignored by .gitignore, + .ignore, etc. in parent dirs. + (default: false) + {search_dirs} (table) directory/directories to search + in builtin.fd() *telescope.builtin.fd()* diff --git a/lua/telescope/builtin/files.lua b/lua/telescope/builtin/files.lua index 578f6de..00c8d78 100644 --- a/lua/telescope/builtin/files.lua +++ b/lua/telescope/builtin/files.lua @@ -153,11 +153,12 @@ files.grep_string = function(opts) }):find() end --- TODO: Maybe just change this to `find`. --- TODO: Support `find` and maybe let people do other stuff with it as well. files.find_files = function(opts) local find_command = (function() if opts.find_command then + if type(opts.find_command) == "function" then + return opts.find_command(opts) + end return opts.find_command elseif 1 == vim.fn.executable "fd" then return { "fd", "--type", "f" } diff --git a/lua/telescope/builtin/init.lua b/lua/telescope/builtin/init.lua index 670b75f..69c83ba 100644 --- a/lua/telescope/builtin/init.lua +++ b/lua/telescope/builtin/init.lua @@ -77,7 +77,7 @@ builtin.grep_string = require_on_exported_call("telescope.builtin.files").grep_s --- Search for files (respecting .gitignore) ---@param opts table: options to pass to the picker ---@field cwd string: root dir to search from (default: cwd, use utils.buffer_dir() to search relative to open buffer) ----@field find_command table: command line arguments for `find_files` to use for the search, overrides default: config +---@field find_command function|table: cmd to use for the search. Can be a fn(opts) -> tbl (default: autodetect) ---@field follow boolean: if true, follows symlinks (i.e. uses `-L` flag for the `find` command) ---@field hidden boolean: determines whether to show hidden files or not (default: false) ---@field no_ignore boolean: show files ignored by .gitignore, .ignore, etc. (default: false)