diff options
| author | TJ DeVries <devries.timothyj@gmail.com> | 2021-04-06 19:59:42 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-04-06 19:59:42 -0400 |
| commit | 0b2c801978e9cfc9b6351fc9f037ff2ba93805bd (patch) | |
| tree | 1a5deff0a60cedcbae81a3883f0a0269c3b90c35 /lua/telescope/make_entry.lua | |
| parent | d0cf646f65746415294f570ec643ffd0101ca3ab (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/make_entry.lua')
| -rw-r--r-- | lua/telescope/make_entry.lua | 20 |
1 files changed, 18 insertions, 2 deletions
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 |
