From 0b2c801978e9cfc9b6351fc9f037ff2ba93805bd Mon Sep 17 00:00:00 2001 From: TJ DeVries Date: Tue, 6 Apr 2021 19:59:42 -0400 Subject: feat: buf highlights for current buffer fuzzy find (#732) * feat: Add buffer highlights from treesitter * fix: Handle not having tree sitter in some buffers * fixup * fixup * fixup: move back to old node --- lua/telescope/make_entry.lua | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'lua/telescope/make_entry.lua') diff --git a/lua/telescope/make_entry.lua b/lua/telescope/make_entry.lua index e4b3d4e..607b8ea 100644 --- a/lua/telescope/make_entry.lua +++ b/lua/telescope/make_entry.lua @@ -685,14 +685,30 @@ function make_entry.gen_from_buffer_lines(opts) separator = ' │ ', items = { { width = 5 }, - { remaining = true }, + { remaining = true, }, }, } local make_display = function(entry) + return displayer { { entry.lnum, opts.lnum_highlight_group or 'TelescopeResultsSpecialComment' }, - entry.line + { + entry.line, function() + if not opts.line_highlights then return {} end + + local line_hl = opts.line_highlights[entry.lnum] or {} + -- TODO: We could probably squash these together if the are the same... + -- But I don't think that it's worth it at the moment. + local result = {} + + for col, hl in pairs(line_hl) do + table.insert(result, { {col, col+1}, hl }) + end + + return result + end + }, } end -- cgit v1.2.3