Skip to content

Add vitual text at cursorline showing index/group/total#72

Open
xzbdmw wants to merge 1 commit into
DNLHC:masterfrom
xzbdmw:feat/virtual_text
Open

Add vitual text at cursorline showing index/group/total#72
xzbdmw wants to merge 1 commit into
DNLHC:masterfrom
xzbdmw:feat/virtual_text

Conversation

@xzbdmw
Copy link
Copy Markdown

@xzbdmw xzbdmw commented Mar 31, 2024

https://github.com/DNLHC/glance.nvim/assets/97848247/1342bd51-549f-4d70-915f-309295811bf3
With this change, I no longer need to look at right list.
If there is only one group, show index/total, otherwise, show index/group/total, from the screenshot above, you can see list cursorline disappears after winscroll, as I mentioned in #70 (comment)

Comment thread lua/glance/list.lua
end

_G.Total_Count = 0
function List:setup(opts)
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure how to pass this information to preview, do you have any suggestions?

Comment thread lua/glance/preview.lua
{
virt_text = {
{ '[' .. cur_index .. '/' .. total_count .. ']', 'NoiceVirtualText' },
},
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The highlight name is waiting for your decision:)

@DNLHC
Copy link
Copy Markdown
Owner

DNLHC commented Apr 3, 2024

Hey, thanks for the PR!
Cool feature, there are however a few things to consider:

  1. I would prefer it to be configurable in case the user wants to disable/enable it.
  2. I don't like that the virtual text is attached to the buffer and not to the preview window, in some cases we can see the index numbers rendered in the background window when we navigate the list. Not ideal.
  3. Having [index/group/total] is more informative but i find it harder to follow than just [index/total]. What do you think?

I was planning to work with virtual text for another feature, was waiting for window local extmarks feature to be merged into neovim neovim/neovim#27361 which should resolve my 2nd point. vim.api.nvim_win_add_ns in particular is interesting. It is now available in nightly release as far as i can tell.

Give me some time to research this extmark thing a bit.

@xzbdmw
Copy link
Copy Markdown
Author

xzbdmw commented Apr 3, 2024

Hi, I don’t know window local extmarks before, that’s nice, it may be used to shift the code in parent window while keep preview window unaffected.

Having [index/group/total] is more informative but i find it harder to follow than just [index/total]. What do you think?

Yes, that can be a format function exposed to users, I’m using 0.10 now and am happy to experiment a bit:)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants