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
This commit is contained in:
TJ DeVries
2021-04-06 19:59:42 -04:00
committed by GitHub
parent d0cf646f65
commit 0b2c801978
5 changed files with 104 additions and 3 deletions

View File

@@ -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