From 8546fdf610584c367f0f1e105aedec370d71bf54 Mon Sep 17 00:00:00 2001 From: Senghan Bright Date: Wed, 2 Dec 2020 00:27:54 +0100 Subject: new builtin - autocommands (#302) * feat: new builtin - Autocommands finder * fix: remove decorators to avoid confusion. * make preview split same hl-group as border * use highlight instead of marker character for preview selection hl --- lua/telescope/make_entry.lua | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'lua/telescope/make_entry.lua') diff --git a/lua/telescope/make_entry.lua b/lua/telescope/make_entry.lua index 2a4ae5c..e1389d4 100644 --- a/lua/telescope/make_entry.lua +++ b/lua/telescope/make_entry.lua @@ -682,4 +682,42 @@ function make_entry.gen_from_ctags(opts) end end +function make_entry.gen_from_autocommands(_) + local displayer = entry_display.create { + separator = "▏", + items = { + { width = 14 }, + { width = 18 }, + { width = 16 }, + { remaining = true }, + }, + } + + local make_display = function(entry) + return displayer { + entry.event, + entry.group, + entry.ft_pattern, + entry.command + } + end + + -- TODO: dump current filtered items to buffer + return function(entry) + return { + event = entry.event, + group = entry.group, + ft_pattern = entry.ft_pattern, + command = entry.command, + value = string.format("+%d %s", entry.source_lnum, entry.source_file), + source_file = entry.source_file, + source_lnum = entry.source_lnum, + -- + valid = true, + ordinal = entry.event .. " " .. entry.group .. " " .. entry.ft_pattern .. " " .. entry.command, + display = make_display, + } + end +end + return make_entry -- cgit v1.2.3