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)
|
function make_entry.gen_from_ctags(opts)
|
||||||
opts = opts or {}
|
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 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 current_file = Path:new(vim.api.nvim_buf_get_name(opts.bufnr)):normalize(cwd)
|
||||||
|
|
||||||
local display_items = {
|
local display_items = {
|
||||||
|
{ width = 16 },
|
||||||
{ remaining = true },
|
{ remaining = true },
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1062,6 +1064,7 @@ function make_entry.gen_from_ctags(opts)
|
|||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
entry.tag,
|
entry.tag,
|
||||||
|
entry.kind,
|
||||||
scode,
|
scode,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
@@ -1089,13 +1092,14 @@ function make_entry.gen_from_ctags(opts)
|
|||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
local tag, file, scode, lnum
|
local tag, file, scode, lnum, extension_fields
|
||||||
-- ctags gives us: 'tags\tfile\tsource'
|
-- ctags gives us: 'tags\tfile\tsource;"extension_fields'
|
||||||
tag, file, scode = string.match(line, '([^\t]+)\t([^\t]+)\t/^?\t?(.*)/;"\t+.*')
|
tag, file, scode, extension_fields = string.match(line, '([^\t]+)\t([^\t]+)\t/^?\t?(.*)/;"\t+(.*)')
|
||||||
if not tag then
|
if not tag then
|
||||||
-- hasktags gives us: 'tags\tfile\tlnum'
|
-- hasktags gives us: 'tags\tfile\tlnum'
|
||||||
tag, file, lnum = string.match(line, "([^\t]+)\t([^\t]+)\t(%d+).*")
|
tag, file, lnum = string.match(line, "([^\t]+)\t([^\t]+)\t(%d+).*")
|
||||||
end
|
end
|
||||||
|
local kind = string.match(extension_fields or "", "kind:(%S+)")
|
||||||
|
|
||||||
if Path.path.sep == "\\" then
|
if Path.path.sep == "\\" then
|
||||||
file = string.gsub(file, "/", "\\")
|
file = string.gsub(file, "/", "\\")
|
||||||
@@ -1124,6 +1128,9 @@ function make_entry.gen_from_ctags(opts)
|
|||||||
tag_entry.filename = file
|
tag_entry.filename = file
|
||||||
tag_entry.col = 1
|
tag_entry.col = 1
|
||||||
tag_entry.lnum = lnum and tonumber(lnum) or 1
|
tag_entry.lnum = lnum and tonumber(lnum) or 1
|
||||||
|
if show_kind then
|
||||||
|
tag_entry.kind = kind
|
||||||
|
end
|
||||||
|
|
||||||
return setmetatable(tag_entry, mt)
|
return setmetatable(tag_entry, mt)
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user