feat: highlight range in previewer #2611
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
I'm currently working on a telescope picker that exposes some
ast-grep
functionalities. Seeing that the match highlighting in the existing previewers is limited to full single line only, I implemented finer-grained range highlighting capabilities in thevim_buffer_vimgrep
previewer to improve match visualization. This could benefit any existing match-based picker.In case this feature is accepted, I have some pending questions:
TelescopePreviewLine
highlights. Should the range highlight use a new hl group and be added on top of the existingTelescopePreviewLine
highlight instead?Closes #933 (if integrated into builtin pickers)
Type of change
How Has This Been Tested?
Telescope live_grep
to make sure its existing previewer match highlighting behaviour didn't change (its entry maker only providescol
,colend
is also needed to opt in)luafile %
with the following custom picker (requires installingast-grep
version ≥0.8.0
).It recursively searches
cwd
for patternprompt
and outputs results with previewer match highlighting. I did some manual tests with various combinations of patterns, buffer text (small/big match, non-ASCII chars) and provided range delimiters in entry maker output (lnum
,lnend
,col
,colend
). For non-ASCII chars, column byte offset is left computed by the user of the previewer, so any issue there should be due to misuse.Configuration:
macOS 11.2.3
NVIM v0.9.1
Build type: Release
LuaJIT 2.1.0-beta3
Checklist: