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/pickers/entry_display.lua | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'lua/telescope/pickers/entry_display.lua') diff --git a/lua/telescope/pickers/entry_display.lua b/lua/telescope/pickers/entry_display.lua index 991c9bc..f64f693 100644 --- a/lua/telescope/pickers/entry_display.lua +++ b/lua/telescope/pickers/entry_display.lua @@ -59,8 +59,16 @@ entry_display.create = function(configuration) hl_start = hl_start + #results[j] + (#configuration.separator or 1) end local hl_end = hl_start + #str:gsub('%s*$', '') - table.insert(highlights, { { hl_start, hl_end }, hl }) + + if type(hl) == "function" then + for _, hl_res in ipairs(hl()) do + table.insert(highlights, { { hl_res[1][1] + hl_start, hl_res[1][2] + hl_start }, hl_res[2] }) + end + else + table.insert(highlights, { { hl_start, hl_end }, hl }) + end end + table.insert(results, str) end end @@ -75,6 +83,7 @@ entry_display.create = function(configuration) table.insert(highlights, { { hl_start, hl_end }, configuration.separator_hl }) end end + local final_str = table.concat(results, configuration.separator or "│") if configuration.hl_chars then for i = 1, #final_str do -- cgit v1.2.3