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

Telescope or similar preview window for referencing/fuzzy finding references #2826

Open
ThSGM opened this issue Nov 13, 2023 · 1 comment
Open

Comments

@ThSGM
Copy link

ThSGM commented Nov 13, 2023

Recently there has been a really significant quality-of-life functionality with the help of @micangl which is the development of the cmp-vimtex plugin, which allows for fuzzy finding of latex references like citations and equations. For me, this has been absolutely essential, so I am eager to see how the plugin develops (and also considerations of direct implementation into vimtex evolves).

I am wondering if it is possible to develop a Telescope-like plugin where you can fuzzy find on labels, but allowing you to preview where the label of such a reference appears.

For example, suppose that my equation is referenced via \label{eq:bigresult}. I would like to press shortcut, pop up a Telescope window, then type 'big' and immediately get a preview of the text where the relevant label appears. Alternatively I can scroll through possible entries and select whichever one is appropriate.

@lervag
Copy link
Owner

lervag commented Nov 22, 2023

ghe closest currently available feature would be the table of contents, which can give functionality close to what you are asking for. You can create custom table of contents, e.g. one that only shows the labels.

E.g., if you add this to your after/ftplugin/tex.vim file:

let g:__vimtex_toc_labels = vimtex#toc#new({
    \ 'name' : 'VimTeX Labels',
    \ 'layers' : ['label'],
    \ 'show_help' : 0,
    \ 'show_numbers' : 0,
    \})
nnoremap <silent> \ly :call g:__vimtex_toc_labels.open()<cr>

Now you can use \ly to open a dedicated toc with only labels. It does not give the preview feature, though, and it is not quite the same as the Telescope selector (you could say it is far from it).

However, it should be quite easy to write a telescope source by use of the same backend. This is close to what we already do for the fzf picker:
https://github.com/lervag/vimtex/blob/master/autoload/vimtex/fzf.vim

This is about 100 lines of code, much of which is not so relevant (theres a lot of formatting and stuff). Now, I don't really need this feature myself, and I'm not an expert at writing Telescope sources. I would not mind helping, but I would be glad if someone else took lead on writing the Telescope picker. If someone did, I would be glad to consider and help out with a PR.

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