From 15f6a0bb08f934bc999c8b5e54fb574f5889558f Mon Sep 17 00:00:00 2001 From: Antoine Date: Thu, 9 Jun 2022 15:54:50 +0200 Subject: [PATCH] feat(tags): process tagfiles on the fly (#1989) --- lua/telescope/builtin/files.lua | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/lua/telescope/builtin/files.lua b/lua/telescope/builtin/files.lua index f078f45..578f6de 100644 --- a/lua/telescope/builtin/files.lua +++ b/lua/telescope/builtin/files.lua @@ -422,6 +422,9 @@ end files.tags = function(opts) local tagfiles = opts.ctags_file and { opts.ctags_file } or vim.fn.tagfiles() + for i, ctags_file in ipairs(tagfiles) do + tagfiles[i] = vim.fn.expand(ctags_file, true) + end if vim.tbl_isempty(tagfiles) then utils.notify("builtin.tags", { msg = "No tags file found. Create one with ctags -R", @@ -429,20 +432,11 @@ files.tags = function(opts) }) return end - - local results = {} - for _, ctags_file in ipairs(tagfiles) do - for line in Path:new(vim.fn.expand(ctags_file, true)):iter() do - results[#results + 1] = line - end - end + opts.entry_maker = vim.F.if_nil(opts.entry_maker, make_entry.gen_from_ctags(opts)) pickers.new(opts, { prompt_title = "Tags", - finder = finders.new_table { - results = results, - entry_maker = opts.entry_maker or make_entry.gen_from_ctags(opts), - }, + finder = finders.new_oneshot_job(flatten { "cat", tagfiles }, opts), previewer = previewers.ctags.new(opts), sorter = conf.generic_sorter(opts), attach_mappings = function()