diff options
| author | Turiiya <34311583+tobealive@users.noreply.github.com> | 2022-07-01 22:10:31 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-07-01 22:10:31 +0200 |
| commit | bf1a25dbfe9a4368b10354cb46e4b3a0ab0a41a4 (patch) | |
| tree | 10ba8b1ac061984db83f310bf24a28a1b4f18009 /lua | |
| parent | 75deb22aa84760bf496427efb7ef0e2660e41bdc (diff) | |
feat: search_file option for builtin fd command (#2029)
Diffstat (limited to 'lua')
| -rw-r--r-- | lua/telescope/builtin/files.lua | 18 | ||||
| -rw-r--r-- | lua/telescope/builtin/init.lua | 1 |
2 files changed, 18 insertions, 1 deletions
diff --git a/lua/telescope/builtin/files.lua b/lua/telescope/builtin/files.lua index d6fa9b4..dddd18a 100644 --- a/lua/telescope/builtin/files.lua +++ b/lua/telescope/builtin/files.lua @@ -201,6 +201,7 @@ files.find_files = function(opts) local no_ignore_parent = opts.no_ignore_parent local follow = opts.follow local search_dirs = opts.search_dirs + local search_file = opts.search_file if search_dirs then for k, v in pairs(search_dirs) do @@ -221,8 +222,16 @@ files.find_files = function(opts) if follow then table.insert(find_command, "-L") end + if search_file then + if command == "rg" then + table.insert(find_command, "-g") + table.insert(find_command, "*" .. search_file .. "*") + else + table.insert(find_command, search_file) + end + end if search_dirs then - if command ~= "rg" then + if command ~= "rg" and not search_file then table.insert(find_command, ".") end for _, v in pairs(search_dirs) do @@ -243,6 +252,10 @@ files.find_files = function(opts) if follow then table.insert(find_command, 2, "-L") end + if search_file then + table.insert(find_command, "-name") + table.insert(find_command, "*" .. search_file .. "*") + end if search_dirs then table.remove(find_command, 2) for _, v in pairs(search_dirs) do @@ -265,6 +278,9 @@ files.find_files = function(opts) if search_dirs ~= nil then log.warn "The `search_dirs` key is not available for the Windows `where` command in `find_files`." end + if search_file ~= nil then + log.warn "The `search_file` key is not available for the Windows `where` command in `find_files`." + end end if opts.cwd then diff --git a/lua/telescope/builtin/init.lua b/lua/telescope/builtin/init.lua index 145338b..71cb583 100644 --- a/lua/telescope/builtin/init.lua +++ b/lua/telescope/builtin/init.lua @@ -83,6 +83,7 @@ builtin.grep_string = require_on_exported_call("telescope.builtin.files").grep_s ---@field no_ignore boolean: show files ignored by .gitignore, .ignore, etc. (default: false) ---@field no_ignore_parent boolean: show files ignored by .gitignore, .ignore, etc. in parent dirs. (default: false) ---@field search_dirs table: directory/directories/files to search +---@field search_file string: specify a filename to search for builtin.find_files = require_on_exported_call("telescope.builtin.files").find_files --- This is an alias for the `find_files` picker |
