diff options
| author | Emilia Simmons <emilia.milisims@gmail.com> | 2021-08-22 18:02:09 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-08-23 01:02:09 +0300 |
| commit | d8eeb0e4acb81ed52bbabc43010f2450c0a7972c (patch) | |
| tree | eb893f300c8811cba81881a0868b09b074279120 /lua | |
| parent | 8381a215e091dc9e1f6ad9ceaeadf35ef3cfed8f (diff) | |
pickers(*): Add support for &tags (#1122)
Diffstat (limited to 'lua')
| -rw-r--r-- | lua/telescope/builtin/files.lua | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/lua/telescope/builtin/files.lua b/lua/telescope/builtin/files.lua index b0cf342..dc6754b 100644 --- a/lua/telescope/builtin/files.lua +++ b/lua/telescope/builtin/files.lua @@ -557,19 +557,22 @@ files.current_buffer_fuzzy_find = function(opts) end files.tags = function(opts) - local ctags_file = opts.ctags_file or "tags" - - if not vim.loop.fs_open(vim.fn.expand(ctags_file, true), "r", 438) then - print "Tags file does not exists. Create one with ctags -R" + local tagfiles = opts.ctags_file and { opts.ctags_file } or vim.fn.tagfiles() + if vim.tbl_isempty(tagfiles) then + print "No tags file found. Create one with ctags -R" return end - local fd = assert(vim.loop.fs_open(vim.fn.expand(ctags_file, true), "r", 438)) - 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)) + 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 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, { prompt_title = "Tags", |
