-
Notifications
You must be signed in to change notification settings - Fork 50
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(render): add support for concealed characters (#153) #156
Conversation
nvim-ufo should work under 0.7.2 version for neovim which is a stable version for ubuntu 22 lts, so don't use a function program API; I suggest you just change the code about |
I'll add I originally attempted to simply add an How does it look now? (before I look into adding |
Before checking the conceal, the |
lua/ufo/render/init.lua
Outdated
for _, m in ipairs(extMarks) do | ||
local hlGroup, conceal = m[5], m[7] | ||
-- next({}) ➜ nil | ||
if conceal or (hlGroup and next(hlGroups[hlGroup])) then |
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.
The origin code checks foreground
attribute because we only capture a single layer, so hl with foreground
is the preferred.
lua/ufo/render/init.lua
Outdated
return aCol < bCol or (aCol == bCol and aPriority < bPriority) | ||
end) | ||
|
||
local virtText = {{'', 'UfoFoldedFg'}} |
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.
If the first char is highlighted, the result will carry this non-sense chunk for the user.
lua/ufo/render/init.lua
Outdated
-- get the most relevant mark | ||
local mark = default | ||
for _, m in ipairs(hlMarks) do | ||
if (mark[6] <= m[6] and m[2] < i and i <= m[4]) then |
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.
The priority of normal hl and conceal are at different levels. conceal should be higher than hl.
lua/ufo/render/init.lua
Outdated
elseif not conceal and hlGroup ~= virtText[#virtText][2] then | ||
table.insert(virtText, {char, hlGroup}) | ||
elseif not conceal then | ||
virtText[#virtText][1] = virtText[#virtText][1] .. char |
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.
The bad situation is the long folded line only with a single hl group, probably making a hundred concation.
That's why I use slots for the original implement to reduce concation. Just let you know my concern, you can ignore it for now.
Added |
Should add concealLevel parameter to |
I think this is good for merge unless there's anything else you can think of! |
Like running `syntax match Search "un" conceal cchar=&` is buggy
Have appended some commits, feel free to review them. No issue will merge into |
local res = {} | ||
local prioritySlots = {} | ||
local hlGroups = highlight.hlGroups() | ||
local concealEabnled = concealLevel > 0 |
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.
%s/concealEabnled/concealEnabled/g
I assume? For this and the next function
Other than typo looks great to me |
Thanks! |
For testing, a simple example would be to add the following to
vim.fn.stdpath('config') .. '/after/queries/lua/highlights.scm'