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

Implementing visual feedback on :VimtexInverseSearch into core vimtex functionality #3039

Open
ThSGM opened this issue Nov 8, 2024 · 3 comments

Comments

@ThSGM
Copy link

ThSGM commented Nov 8, 2024

I recently asked for a feature where activating the InverseSearch functionality would centre and highlight the area in the document where the location was being referenced. @lervag implemented a very nice attempt at this: #3038

Here was the prototype:

augroup vimtex_event_5
  au!
  au User VimtexEventViewReverse call CenterAndFlash()
augroup END

function! CenterAndFlash() abort
  " Center on cursor position
  normal! zz

  let save_cursorline_state = &cursorline

  " Add simple flashing effect, see
  " * https://vi.stackexchange.com/a/3481/29697
  " * https://stackoverflow.com/a/33775128/38281
  for i in range(1, 3)
    set cursorline
    redraw
    sleep 200m
    set nocursorline
    redraw
    sleep 200m
  endfor

  let &cursorline = save_cursorline_state
endfunction

This feature has been very valuable to me during testing. The InverseSearch functionality can sometimes be flakey: for example, it can be unclear if your PDF is 'focused', which means you may need to click 2-3 times for the search to happen. It can be also be hard to detect where in a tex document it is referencing.

I want to propose that this feature be implemented into the core vimtex functionality. Some additional thoughts:

  • Can the centering operation be made with more visual feedback. Instead of a jump, can the tex document be scrolled, similar to the vim-smoothie plugin? This gives really good visual feedback: it allows you to discern where the document is being jumped to, and the amount it has moved.
  • Can we implement more distinct highlighting? The current highlight uses the cursorline colour, which is usually very subtle. Some latex editors that do this won't use a highlight but instead use something like a big red dot.
@lervag
Copy link
Owner

lervag commented Nov 8, 2024

Thanks! I'll look into this when I get the time!

@lervag
Copy link
Owner

lervag commented Dec 28, 2024

The InverseSearch functionality can sometimes be flakey: for example, it can be unclear if your PDF is 'focused', which means you may need to click 2-3 times for the search to happen.

Is this thing relevant to the current feature request? If so, then I don't understand what you mean here.

It can be also be hard to detect where in a tex document it is referencing.

This is also somewhat unclear and it may help if you explain more what you mean. That is, what exactly is hard?

I want to propose that this feature be implemented into the core vimtex functionality.

I think it can be added, but it would be nice to avoid options here. I believe a simple and efficient visual feedback could be added without any options. But I'm not 100% sure about centering. Perhaps that would also be good.

Some additional thoughts:

  • Can the centering operation be made with more visual feedback. Instead of a jump, can the tex document be scrolled, similar to the vim-smoothie plugin? This gives really good visual feedback: it allows you to discern where the document is being jumped to, and the amount it has moved.

I'm curious, is it really necessary to replicate this feature? I mean, if you want smooth scrolling, can you not just use the plugin?

  • Can we implement more distinct highlighting? The current highlight uses the cursorline colour, which is usually very subtle. Some latex editors that do this won't use a highlight but instead use something like a big red dot.

On neovim, I think we can use extmarks for this. And I guess there are something similar on Vim. I'll look into it. But I think I'll go with the cursorline method as a first step and fallback method.

@lervag
Copy link
Owner

lervag commented Dec 28, 2024

I've added an initial version of this now. It adds the highlight VimtexBlink that you can customize to choose your desired highlighting for the blinking. It works on both Vim and neovim. The main code is here:

e4e5d9f#diff-cb0e46c70888bf8fe253c275dcf6f896f70d5a8db18acc1e953bbb06742c2b53R169

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

No branches or pull requests

2 participants