Skip to content

Commit 21bfcc3

Browse files
ecerulmrubelaguGithub Actions
authored
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 <[email protected]> Co-authored-by: Github Actions <actions@github>
1 parent b324469 commit 21bfcc3

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

lua/telescope/make_entry.lua

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,10 +1017,12 @@ end
10171017
function make_entry.gen_from_ctags(opts)
10181018
opts = opts or {}
10191019

1020+
local show_kind = vim.F.if_nil(opts.show_kind, true)
10201021
local cwd = utils.path_expand(opts.cwd or vim.loop.cwd())
10211022
local current_file = Path:new(vim.api.nvim_buf_get_name(opts.bufnr)):normalize(cwd)
10221023

10231024
local display_items = {
1025+
{ width = 16 },
10241026
{ remaining = true },
10251027
}
10261028

@@ -1062,6 +1064,7 @@ function make_entry.gen_from_ctags(opts)
10621064
end,
10631065
},
10641066
entry.tag,
1067+
entry.kind,
10651068
scode,
10661069
}
10671070
end
@@ -1089,13 +1092,14 @@ function make_entry.gen_from_ctags(opts)
10891092
return nil
10901093
end
10911094

1092-
local tag, file, scode, lnum
1093-
-- ctags gives us: 'tags\tfile\tsource'
1094-
tag, file, scode = string.match(line, '([^\t]+)\t([^\t]+)\t/^?\t?(.*)/;"\t+.*')
1095+
local tag, file, scode, lnum, extension_fields
1096+
-- ctags gives us: 'tags\tfile\tsource;"extension_fields'
1097+
tag, file, scode, extension_fields = string.match(line, '([^\t]+)\t([^\t]+)\t/^?\t?(.*)/;"\t+(.*)')
10951098
if not tag then
10961099
-- hasktags gives us: 'tags\tfile\tlnum'
10971100
tag, file, lnum = string.match(line, "([^\t]+)\t([^\t]+)\t(%d+).*")
10981101
end
1102+
local kind = string.match(extension_fields or "", "kind:(%S+)")
10991103

11001104
if Path.path.sep == "\\" then
11011105
file = string.gsub(file, "/", "\\")
@@ -1124,6 +1128,9 @@ function make_entry.gen_from_ctags(opts)
11241128
tag_entry.filename = file
11251129
tag_entry.col = 1
11261130
tag_entry.lnum = lnum and tonumber(lnum) or 1
1131+
if show_kind then
1132+
tag_entry.kind = kind
1133+
end
11271134

11281135
return setmetatable(tag_entry, mt)
11291136
end

0 commit comments

Comments
 (0)