Skip to content
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

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

xzbdmw
Copy link

@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)

@@ -371,12 +371,14 @@ local function get_lsp_method_label(method_name)
return utils.capitalize(lsp.methods[method_name].label)
end

_G.Total_Count = 0
function List:setup(opts)
Copy link
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?

{
virt_text = {
{ '[' .. cur_index .. '/' .. total_count .. ']', 'NoiceVirtualText' },
},
Copy link
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
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
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.

None yet

2 participants