summaryrefslogtreecommitdiff
path: root/lua/telescope/pickers/entry_display.lua
diff options
context:
space:
mode:
authorTJ DeVries <devries.timothyj@gmail.com>2021-04-06 19:59:42 -0400
committerGitHub <noreply@github.com>2021-04-06 19:59:42 -0400
commit0b2c801978e9cfc9b6351fc9f037ff2ba93805bd (patch)
tree1a5deff0a60cedcbae81a3883f0a0269c3b90c35 /lua/telescope/pickers/entry_display.lua
parentd0cf646f65746415294f570ec643ffd0101ca3ab (diff)
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
Diffstat (limited to 'lua/telescope/pickers/entry_display.lua')
-rw-r--r--lua/telescope/pickers/entry_display.lua11
1 files changed, 10 insertions, 1 deletions
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