summaryrefslogtreecommitdiff
path: root/lua/telescope/make_entry.lua
diff options
context:
space:
mode:
authorSimon Hauser <Simon-Hauser@outlook.de>2020-11-16 21:17:13 +0100
committerGitHub <noreply@github.com>2020-11-16 15:17:13 -0500
commiteaa7011f8499f2c8c473a5beb50100f1cae006cf (patch)
tree6b004689f95f0cf93b476428f3543a29a3483559 /lua/telescope/make_entry.lua
parent81172630270325947d2c6b3afda5599e34b48499 (diff)
feat: Add tags (#219)
Diffstat (limited to 'lua/telescope/make_entry.lua')
-rw-r--r--lua/telescope/make_entry.lua69
1 files changed, 69 insertions, 0 deletions
diff --git a/lua/telescope/make_entry.lua b/lua/telescope/make_entry.lua
index 906eb95..57344ab 100644
--- a/lua/telescope/make_entry.lua
+++ b/lua/telescope/make_entry.lua
@@ -559,4 +559,73 @@ function make_entry.gen_from_vimoptions(opts)
end
end
+function make_entry.gen_from_ctags(opts)
+ opts = opts or {}
+
+ local cwd = vim.fn.expand(opts.cwd or vim.fn.getcwd())
+ local current_file = path.normalize(vim.fn.expand('%'), cwd)
+
+ local display_items = {
+ { width = 30 },
+ { remaining = true },
+ }
+
+ if opts.show_line then
+ table.insert(display_items, 2, { width = 30 })
+ end
+
+ local displayer = entry_display.create {
+ separator = " │ ",
+ items = display_items,
+ }
+
+ local make_display = function(entry)
+ local filename
+ if not opts.hide_filename then
+ if opts.shorten_path then
+ filename = path.shorten(entry.filename)
+ else
+ filename = entry.filename
+ end
+ end
+
+ local scode
+ if opts.show_line then
+ scode = entry.scode
+ end
+
+ return displayer {
+ filename,
+ entry.tag,
+ scode,
+ }
+ end
+
+ return function(line)
+ if line == '' or line:sub(1, 1) == '!' then
+ return nil
+ end
+
+ local tag, file, scode = string.match(line, '([^\t]+)\t([^\t]+)\t/^\t?(.*)/;"\t+.*')
+
+ if opts.only_current_file and file ~= current_file then
+ return nil
+ end
+
+ return {
+ valid = true,
+
+ ordinal = file .. ': ' .. tag,
+ display = make_display,
+ scode = scode,
+ tag = tag,
+
+ filename = file,
+
+ col = 1,
+ lnum = 1,
+ }
+ end
+end
+
return make_entry