Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Fix tagrelative option not considered in builtin.tags (#2583)" #2629

Merged
merged 1 commit into from
Aug 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 1 addition & 18 deletions lua/telescope/builtin/__files.lua
Original file line number Diff line number Diff line change
Expand Up @@ -529,23 +529,6 @@ files.current_buffer_fuzzy_find = function(opts)
end

files.tags = function(opts)
-- find lines not matching tags file format (begins with !) or empty lines.
local tags_command = (function()
if 1 == vim.fn.executable "rg" then
return { "rg", "-H", "-N", "--no-heading", "--color", "never", "-v", "^!|^$" }
elseif 1 == vim.fn.executable "grep" then
return { "grep", "-H", "--color=never", "-v", "^!\\|^$" }
end
end)()

if not tags_command then
utils.notify("builtin.tags", {
msg = "You need to install either grep or rg",
level = "ERROR",
})
return
end

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)
Expand All @@ -562,7 +545,7 @@ files.tags = function(opts)
pickers
.new(opts, {
prompt_title = "Tags",
finder = finders.new_oneshot_job(flatten { tags_command, tagfiles }, opts),
finder = finders.new_oneshot_job(flatten { "cat", tagfiles }, opts),
previewer = previewers.ctags.new(opts),
sorter = conf.generic_sorter(opts),
attach_mappings = function()
Expand Down
12 changes: 3 additions & 9 deletions lua/telescope/make_entry.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1086,9 +1086,9 @@ function make_entry.gen_from_ctags(opts)

local current_file_cache = {}
return function(line)
local tag_file
-- split line by ':'
tag_file, line = string.match(line, "([^:]+):(.+)")
if line == "" or line:sub(1, 1) == "!" then
return nil
end

local tag, file, scode, lnum
-- ctags gives us: 'tags\tfile\tsource'
Expand All @@ -1098,12 +1098,6 @@ function make_entry.gen_from_ctags(opts)
tag, file, lnum = string.match(line, "([^\t]+)\t([^\t]+)\t(%d+).*")
end

-- append tag file path
if vim.opt.tagrelative:get() then
local tag_path = Path:new(tag_file):parent()
file = Path:new(tag_path .. "/" .. file):normalize(cwd)
end

if Path.path.sep == "\\" then
file = string.gsub(file, "/", "\\")
end
Expand Down