From d0cf646f65746415294f570ec643ffd0101ca3ab Mon Sep 17 00:00:00 2001 From: August Masquelier <31262046+levouh@users.noreply.github.com> Date: Sun, 4 Apr 2021 05:04:06 -0600 Subject: feat: current buffer fuzzy find improvements (#694) If you don't want to have a previewer disable it with `:Telescope current_buffer_fuzzy_find previewer=false` To ignore empty lines do: `:Telescope current_buffer_fuzzy_find skip_empty_lines=true` --- lua/telescope/make_entry.lua | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'lua/telescope/make_entry.lua') diff --git a/lua/telescope/make_entry.lua b/lua/telescope/make_entry.lua index dd31193..e4b3d4e 100644 --- a/lua/telescope/make_entry.lua +++ b/lua/telescope/make_entry.lua @@ -680,6 +680,38 @@ function make_entry.gen_from_highlights() end end +function make_entry.gen_from_buffer_lines(opts) + local displayer = entry_display.create { + separator = ' │ ', + items = { + { width = 5 }, + { remaining = true }, + }, + } + + local make_display = function(entry) + return displayer { + { entry.lnum, opts.lnum_highlight_group or 'TelescopeResultsSpecialComment' }, + entry.line + } + end + + return function(entry) + if opts.skip_empty_lines and string.match(entry.line, '^$') then + return + end + + return { + valid = true, + ordinal = entry.line, + display = make_display, + filename = entry.filename, + lnum = entry.lnum, + line = entry.line, + } + end +end + function make_entry.gen_from_vimoptions() local process_one_opt = function(o) local ok, value_origin -- cgit v1.2.3