pickers(*): Add support for &tags (#1122)

This commit is contained in:
Emilia Simmons
2021-08-22 18:02:09 -04:00
committed by GitHub
parent 8381a215e0
commit d8eeb0e4ac

View File

@@ -557,19 +557,22 @@ files.current_buffer_fuzzy_find = function(opts)
end end
files.tags = function(opts) files.tags = function(opts)
local ctags_file = opts.ctags_file or "tags" local tagfiles = opts.ctags_file and { opts.ctags_file } or vim.fn.tagfiles()
if vim.tbl_isempty(tagfiles) then
if not vim.loop.fs_open(vim.fn.expand(ctags_file, true), "r", 438) then print "No tags file found. Create one with ctags -R"
print "Tags file does not exists. Create one with ctags -R"
return return
end end
local results = {}
for _, ctags_file in ipairs(tagfiles) do
local fd = assert(vim.loop.fs_open(vim.fn.expand(ctags_file, true), "r", 438)) local fd = assert(vim.loop.fs_open(vim.fn.expand(ctags_file, true), "r", 438))
local stat = assert(vim.loop.fs_fstat(fd)) local stat = assert(vim.loop.fs_fstat(fd))
local data = assert(vim.loop.fs_read(fd, stat.size, 0))
assert(vim.loop.fs_close(fd)) assert(vim.loop.fs_close(fd))
local results = vim.split(data, "\n") for line in Path:new(vim.fn.expand(ctags_file)):iter() do
results[#results + 1] = line
end
end
pickers.new(opts, { pickers.new(opts, {
prompt_title = "Tags", prompt_title = "Tags",