diff --git a/doc/telescope.txt b/doc/telescope.txt index bb43329500..bd7b1ed4e3 100644 --- a/doc/telescope.txt +++ b/doc/telescope.txt @@ -864,9 +864,10 @@ builtin.live_grep({opts}) *telescope.builtin.live_grep()* {glob_pattern} (string|table) argument to be used with `--glob`, e.g. "*.toml", can use the opposite "!*.toml" - {type_filter} (string) argument to be used with - `--type`, e.g. "rust", see `rg - --type-list` + {type_filter} (string|table) comma-separated string or + string list argument to be + used with `--type`, e.g. "rust", + see `rg --type-list` {additional_args} (function|table) additional arguments to be passed on. Can be fn(opts) -> tbl diff --git a/lua/telescope/builtin/__files.lua b/lua/telescope/builtin/__files.lua index 27b8d1c927..650bb41775 100644 --- a/lua/telescope/builtin/__files.lua +++ b/lua/telescope/builtin/__files.lua @@ -138,7 +138,13 @@ files.live_grep = function(opts) end if opts.type_filter then - additional_args[#additional_args + 1] = "--type=" .. opts.type_filter + local file_types = opts.type_filter + if type(opts.type_filter) == "string" then + file_types = vim.split(opts.type_filter, ",", { trimempty = true }) + end + for _, file_type in ipairs(file_types) do + additional_args[#additional_args + 1] = "--type=" .. file_type + end end if type(opts.glob_pattern) == "string" then diff --git a/lua/telescope/builtin/init.lua b/lua/telescope/builtin/init.lua index 6e27c27ab3..89e969d2d3 100644 --- a/lua/telescope/builtin/init.lua +++ b/lua/telescope/builtin/init.lua @@ -51,7 +51,7 @@ end ---@field grep_open_files boolean: if true, restrict search to open files only, mutually exclusive with `search_dirs` ---@field search_dirs table: directory/directories/files to search, mutually exclusive with `grep_open_files` ---@field glob_pattern string|table: argument to be used with `--glob`, e.g. "*.toml", can use the opposite "!*.toml" ----@field type_filter string: argument to be used with `--type`, e.g. "rust", see `rg --type-list` +---@field type_filter string|table: comma-separated string or string list argument to be used with `--type`, e.g. "rust", see `rg --type-list` ---@field additional_args function|table: additional arguments to be passed on. Can be fn(opts) -> tbl ---@field max_results number: define a upper result value ---@field disable_coordinates boolean: don't show the line & row numbers (default: false)