feat(tags): process tagfiles on the fly (#1989)

This commit is contained in:
Antoine
2022-06-09 15:54:50 +02:00
committed by Simon Hauser
parent 8488cd5ac7
commit 15f6a0bb08

View File

@@ -422,6 +422,9 @@ end
files.tags = function(opts) files.tags = function(opts)
local tagfiles = opts.ctags_file and { opts.ctags_file } or vim.fn.tagfiles() 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 if vim.tbl_isempty(tagfiles) then
utils.notify("builtin.tags", { utils.notify("builtin.tags", {
msg = "No tags file found. Create one with ctags -R", msg = "No tags file found. Create one with ctags -R",
@@ -429,20 +432,11 @@ files.tags = function(opts)
}) })
return return
end end
opts.entry_maker = vim.F.if_nil(opts.entry_maker, make_entry.gen_from_ctags(opts))
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
pickers.new(opts, { pickers.new(opts, {
prompt_title = "Tags", prompt_title = "Tags",
finder = finders.new_table { finder = finders.new_oneshot_job(flatten { "cat", tagfiles }, opts),
results = results,
entry_maker = opts.entry_maker or make_entry.gen_from_ctags(opts),
},
previewer = previewers.ctags.new(opts), previewer = previewers.ctags.new(opts),
sorter = conf.generic_sorter(opts), sorter = conf.generic_sorter(opts),
attach_mappings = function() attach_mappings = function()