Skip to content

Commit

Permalink
Allow table as additional args in grep string + docs
Browse files Browse the repository at this point in the history
  • Loading branch information
gepbird committed Aug 19, 2022
1 parent 3e662ca commit 955ec37
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions lua/telescope/builtin/__files.lua
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,12 @@ files.grep_string = function(opts)
local search = opts.use_regex and word or escape_chars(word)

local additional_args = {}
if opts.additional_args ~= nil and type(opts.additional_args) == "function" then
additional_args = opts.additional_args(opts)
if opts.additional_args ~= nil then
if type(opts.additional_args) == "function" then
additional_args = opts.additional_args(opts)
elseif type(opts.additional_args) == "table" then
additional_args = opts.additional_args
end
end

if search == "" then
Expand Down
2 changes: 1 addition & 1 deletion lua/telescope/builtin/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ builtin.live_grep = require_on_exported_call("telescope.builtin.__files").live_g
---@field search_dirs table: directory/directories/files to search, mutually exclusive with `grep_open_files`
---@field use_regex boolean: if true, special characters won't be escaped, allows for using regex (default: false)
---@field word_match string: can be set to `-w` to enable exact word matches
---@field additional_args function: function(opts) which returns a table of additional arguments to be passed on
---@field additional_args function|table: additional arguments to be passed on. Can be fn(opts) -> tbl
---@field disable_coordinates boolean: don't show the line and row numbers (default: false)
---@field only_sort_text boolean: only sort the text, not the file, line or row (default: false)
builtin.grep_string = require_on_exported_call("telescope.builtin.__files").grep_string
Expand Down

0 comments on commit 955ec37

Please sign in to comment.