pickers(*): Add support for &tags (#1122)
This commit is contained in:
@@ -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 fd = assert(vim.loop.fs_open(vim.fn.expand(ctags_file, true), "r", 438))
|
local results = {}
|
||||||
local stat = assert(vim.loop.fs_fstat(fd))
|
for _, ctags_file in ipairs(tagfiles) do
|
||||||
local data = assert(vim.loop.fs_read(fd, stat.size, 0))
|
local fd = assert(vim.loop.fs_open(vim.fn.expand(ctags_file, true), "r", 438))
|
||||||
assert(vim.loop.fs_close(fd))
|
local stat = assert(vim.loop.fs_fstat(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",
|
||||||
|
|||||||
Reference in New Issue
Block a user