mirror of
https://github.com/zoriya/telescope.nvim.git
synced 2025-12-06 06:46:10 +00:00
ctags filtering with grep or rg and normalize path
This commit is contained in:
@@ -529,11 +529,12 @@ 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", "^" }
|
||||
return { "rg", "-H", "-N", "--no-heading", "--color", "never", "-v", "^!|^$" }
|
||||
elseif 1 == vim.fn.executable "grep" then
|
||||
return { "grep", "-H", "--color=never", "^"}
|
||||
return { "grep", "-H", "--color=never", "-v", "^!\\|^$"}
|
||||
end
|
||||
end)()
|
||||
|
||||
|
||||
@@ -1086,17 +1086,10 @@ function make_entry.gen_from_ctags(opts)
|
||||
|
||||
local current_file_cache = {}
|
||||
return function(line)
|
||||
if line == "" then
|
||||
return nil
|
||||
end
|
||||
local tag_file
|
||||
-- split line by ':'
|
||||
tag_file, line = string.match(line, '([^:]+):(.+)')
|
||||
|
||||
-- do not include tag file format
|
||||
if line:sub(1, 1) == "!" then
|
||||
return nil
|
||||
end
|
||||
|
||||
local tag, file, scode, lnum
|
||||
-- ctags gives us: 'tags\tfile\tsource'
|
||||
tag, file, scode = string.match(line, '([^\t]+)\t([^\t]+)\t/^?\t?(.*)/;"\t+.*')
|
||||
@@ -1107,8 +1100,8 @@ function make_entry.gen_from_ctags(opts)
|
||||
|
||||
-- append tag file path
|
||||
if vim.opt.tagrelative:get() then
|
||||
local tag_path = Path:new(tag_file):parent():make_relative(cwd)
|
||||
file = tag_path .. "/" .. file
|
||||
local tag_path = Path:new(tag_file):parent()
|
||||
file = Path:new(tag_path .. "/" .. file):normalize(cwd)
|
||||
end
|
||||
|
||||
if Path.path.sep == "\\" then
|
||||
|
||||
Reference in New Issue
Block a user