ctags filtering with grep or rg and normalize path

This commit is contained in:
Oscar Creator
2023-06-25 15:10:33 +02:00
parent f79c884bee
commit ba0073caeb
2 changed files with 6 additions and 12 deletions

View File

@@ -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)()

View File

@@ -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