-
Notifications
You must be signed in to change notification settings - Fork 90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Adds syntax highlighting in the telescope picker #386
feat: Adds syntax highlighting in the telescope picker #386
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR! Left a few comments
lua/telescope/_extensions/aerial.lua
Outdated
local ts_parsers = require("nvim-treesitter.parsers") | ||
local ts_query = require("nvim-treesitter.query") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This introduces a hard dependency on nvim-treesitter. Could this be reworked to only use the built-in vim.treesitter APIs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, works as well w/o it, done
lua/telescope/_extensions/aerial.lua
Outdated
for _, value in ipairs(buf_highlights) do | ||
local start_row, start_col, end_row, end_col = unpack(value.range) | ||
|
||
if start_row == row then | ||
local type = value.capture:gsub("%..*", "") -- strip subtypes after dot | ||
table.insert(highlights, { { start_col + offset, end_col + offset }, type }) | ||
end | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks like an n-squared algorithm; I would expect it to lag on large files. Could we instead store the buf_highlights in a structure that is indexed by the start_row?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done, updated to index based way
lua/telescope/_extensions/aerial.lua
Outdated
only_lines = false, | ||
show_lines = true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This introduces the possibility for a nonsensical configuration (only_lines = true
and show_lines = false
).
Could we instead have one configuration option show_columns
that can be "symbols", "lines", or "both"? And then add a shim so the old show_lines
option continues to work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated to show_columns way
@stevearc all updated, please review |
LGTM, thanks for the PR! |
the highlighting for the symbol type and the symbol name were lost with that change.
the highlighting for the symbol type and the symbol name were lost with that change.
* fix telescope highlights regression from #386 the highlighting for the symbol type and the symbol name were lost with that change. * fix: telescope highlighting accounts for multibyte characters * telescope: allow to configure column widths --------- Co-authored-by: Steven Arcangeli <[email protected]>
Adds syntax highlighting in the telescope picker. Issue #384
only_lines
picker config to show only code w/o symbols.Some results:
with
only_lines=true
Other notes:
only_lines
- tried to name it in existing naming syntax, no any preferences, up to you