mirror of
https://github.com/zoriya/telescope.nvim.git
synced 2025-12-06 06:46:10 +00:00
feat(tags): add support for displaying tag kind (#3235)
* Add kind to builtin.tags picker * Add show_kind option * Make show_kind true by default * [docgen] Update doc/telescope.txt skip-checks: true * lint --------- Co-authored-by: Ruben Laguna <ruben.laguna@tele2.com> Co-authored-by: Github Actions <actions@github>
This commit is contained in:
@@ -1017,10 +1017,12 @@ end
|
||||
function make_entry.gen_from_ctags(opts)
|
||||
opts = opts or {}
|
||||
|
||||
local show_kind = vim.F.if_nil(opts.show_kind, true)
|
||||
local cwd = utils.path_expand(opts.cwd or vim.loop.cwd())
|
||||
local current_file = Path:new(vim.api.nvim_buf_get_name(opts.bufnr)):normalize(cwd)
|
||||
|
||||
local display_items = {
|
||||
{ width = 16 },
|
||||
{ remaining = true },
|
||||
}
|
||||
|
||||
@@ -1062,6 +1064,7 @@ function make_entry.gen_from_ctags(opts)
|
||||
end,
|
||||
},
|
||||
entry.tag,
|
||||
entry.kind,
|
||||
scode,
|
||||
}
|
||||
end
|
||||
@@ -1089,13 +1092,14 @@ function make_entry.gen_from_ctags(opts)
|
||||
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+.*')
|
||||
local tag, file, scode, lnum, extension_fields
|
||||
-- ctags gives us: 'tags\tfile\tsource;"extension_fields'
|
||||
tag, file, scode, extension_fields = string.match(line, '([^\t]+)\t([^\t]+)\t/^?\t?(.*)/;"\t+(.*)')
|
||||
if not tag then
|
||||
-- hasktags gives us: 'tags\tfile\tlnum'
|
||||
tag, file, lnum = string.match(line, "([^\t]+)\t([^\t]+)\t(%d+).*")
|
||||
end
|
||||
local kind = string.match(extension_fields or "", "kind:(%S+)")
|
||||
|
||||
if Path.path.sep == "\\" then
|
||||
file = string.gsub(file, "/", "\\")
|
||||
@@ -1124,6 +1128,9 @@ function make_entry.gen_from_ctags(opts)
|
||||
tag_entry.filename = file
|
||||
tag_entry.col = 1
|
||||
tag_entry.lnum = lnum and tonumber(lnum) or 1
|
||||
if show_kind then
|
||||
tag_entry.kind = kind
|
||||
end
|
||||
|
||||
return setmetatable(tag_entry, mt)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user