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
[conceal] \cite, \citep, \citet to key list or just a simple marker #1965
Comments
I don't think Vim can do this type of "advanced" conceals, that is, we can only do relatively simple replacements. To be able to answer/consider this request more clearly, perhaps you could show some examples of specifically how you would like this to work? I think the following shows approximately what I think can be achieved: % Raw tex
See e.g. \cite{myref} for more info.
\citet{myref} show that ...
% Concealed
See e.g. [myref] for more info.
[myref] show that ... A "perfect" solution would of course parse the reference key, but I think that is impossible (or at least too hard for me to consider). Further, a perfect solution would differentiate |
No need for it to be perfect. And yes, I know the conceal is iffy... e.g. for C++ I couldn't even manage to get it to conceal Parsing the reference key is definitely impossible in the general case, and not worth the effort. Is it hard to "throw away" the insides of the concealed boundaries? |
Good to hear we agree on that.
Well, if we concealed
I'm not sure what you mean, please try to show by example (raw vs "concealed variant"). So far, it seems my listing in the previous comment seems like an acceptable proposal for the feature. |
I know in reality the citstion depends on style factor, but when it comes to reading the source text of the document, (In many cases, the bib keys for stuff doesn't even make sense, sites generare either an auto increment ID (like IEEE) or the DOI (like ACM or Springer) as the bibkey.) |
I would propose an option: % Raw TeX
Bla bla bla, see Ref.~\cite{John2012Measurement,Anne2017Bifurcation}. For more info, see also \cite{Bob2025Mystery}.
% Concealed with g:vimtex_syntax_conceal = {'cites': 1}
Bla bla bla, see Ref.~[X]. For more info, see also [X].
% Concealed with g:vimtex_syntax_conceal = {'cites': 2}
Bla bla bla, see Ref.~[John2012Measurement,Anne2017Bifurcation]. For more info, see also [Bob2025Mystery]. If you think this looks like a sufficient summary, then I'll look into if it is doable (without too much "hacking"). |
I like the idea. Maybe instead of a numbers |
Perhaps this is too difficult to implement, but it would be awesome if VimTeX showed the citation that would be generated in the PDF. For instance the number that For example, given
It would be awesome if the concealed text looked something like above. The VimTeX feature doesn't necessarily have to look at the value of Again, this may be way too difficult to implement, but I just want to throw the idea out. |
Ah, yes, I'm sorry. This is too hard. The syntax conceal feature in Vim/neovim is quite limited (see So, to achieve |
Definitely impossible to implement, and not just because of Vim's limited functionality, but to do this, you'd need to either: reimplement a significant part of the compilers, or use an integration that jacks into the actual compilers (like clangd for C/C++) and retrieves this data. This is an overexaggeration and I didn't look into it scientifically, but LaTeX is at least Turing-complete, but there is a high chance that the grammar is so deeply context-sensitive that it's undecidable in the general case. (C++ has similar issues in many case.) And, come on, to build a LaTeX document with cites, you have to run the compiler at least three times(!!!), plus bibtex somewhere down that road, and what And this gets even worse when you got bib styles which are some sort of author-year combination, and the author names contain escape sequences or are generated by macros, etc... I am not saying this is completely impossible, but it would require both more than the conceal feature, and some true compiler integration... Personal suggestion about bloats and whatnot: first, function! ToggleConcealLevel()
if &conceallevel == 0
setlocal conceallevel=2
else
setlocal conceallevel=0
endif
endfunction
nnoremap <silent> <C-c><C-y> :call ToggleConcealLevel()<CR> |
There is one issue with conceal that I found is that it seems the same location in the buffer can't have multiple concealments apply. I could never manage to differently conceal |
Sorry, but I don't quite understand how you would want that C/C++ conceal. Reg. multiple concealments: it doesn't really make sense to apply multiple conceals at the same position. Conceal is basically used to hide text, but it does allow to replace with a single character. If something is hidden, you can't hide it more. |
Mind, I do not want it from you! But basically what I was is to have one character conceal for if (foo) {
return 1;
} else if (bar) {
return 2;
} else {
return 3;
} in concealment to look like this: ▸ (foo) {
⏎ 0;
} ▹ (bar) {
⏎ 1;
} ▪ {
⏎ 2;
} But instead, it looks like this (note that ▸ (foo) {
⏎ 0;
} ▪ ▸ (bar) {
⏎ 1;
} ▪ {
⏎ 2;
} |
An alternative to replacing citations with % Raw TeX
Bla bla bla, see Ref.~\cite{John2012Measurement,Anne2017Bifurcation}. For more info, see also \cite{Bob2025Mystery}.
% Concealing with unicode symbol
Bla bla bla, see Ref.~🕮. For more info, see also 🕮. Perhaps the exact symbol used could be customizable by the user so that they could use a nerd font glyph if they wanted. |
This should be possible. You need to understand the order of syntax statements. The last one is checked first. So, you need to add the @Melkster I actually like that suggestion a lot. It is much easier to implement than @whisperity What do you think? |
I like the idea. But definitely make the symbol customisable, some terminal emulators (such as Konsole) have biiig problems with rendering glpyhs properly. |
I personally don't use |
Normally I don't want to either, but a recent paper I submitted required a weird format and authoryear cites instead of the IEEE one, for which I had to use |
Actually, it is smart to use |
Then I propose the following:
Simple and straightforward. We can consider improvements when it is done. Does it sound OK? |
So the |
Exactly. :) |
@lervag Sounds like a good start! I also liked the previous idea with concealing % Raw TeX
Bla bla bla, see Ref.~\cite{John2012Measurement,Anne2017Bifurcation}. For more info, see also \cite{Bob2025Mystery}.
% Concealed with g:vimtex_syntax_conceal = {'cites': 2}
Bla bla bla, see Ref.~[John2012Measurement,Anne2017Bifurcation]. For more info, see also [Bob2025Mystery]. Perhaps there could be an option added later for this as well? |
I'm not quite sure about this. I've pushed a PR with the previously discussed feature where the entire cite command is replaced with a single character. However, since Vim and neovim does not reflow the text, I think the benefit is not enough. But I'll let you people decide - I'll not be using it myself in any case. I think I would prefer to only support a single type of conceals here, so let's discuss this. Perhaps a better choice is the bracketed version where |
In general when writing (La)TeX, you should not be putting two sentences on the same line anyways, similar to how you rarely put two full expressions on the same line when writing a program! Makes it really wonky to move around sentences or cut out sentences (e.g. when you happen to go over the limit of the journal you're submitting to and need to rewrite some sentences). |
I tend to agree, but it is not up to me to enforce such rules. VimTeX should work well regardless of how people work. So, the questions:
|
Yeah. I like it. If it is by itself, if it is fine. If not, then see answer to the next point.
The And then the default behaviour could be that |
Or you could simply call them |
I personally kinda like having both options available.
I would suggest the name Then there could be a second variable called |
A slight "problem" is that all the other conceal configuration options are booleans. So this would create a dissonance. Not a problem for me, but might be a sore thorn when looked at.
If we accept the fact that the symmetry of the flags being bools are broken, then we could roll with just one configuration option. It could be |
I've implemented and pushed a solution now. Comments are more than welcome! Please checkout the PR #2002. To test:
|
This should now work, but let me know if I've missed something! |
@lervag Could you please also add the Oh yeah, I'm working on a presentation now, and realised there is a separate command for Beamer-y stuff. |
Is |
It seems like it's coming from |
Done. |
This is a suggestion request to extend Vimtex's conceal feature with handling
\cite
,\citep
, and\citet
. If possible, it should be concealed out with either a(...)
(where...
is the bib key for the cited work), or with[X]
whereX
is a literalX
to show there is a citation there, instead of the lengthy sequence a bib key could take.Unfortunately, I'm not sure if conceal can handle "parsing" such elaborate sequences.
The text was updated successfully, but these errors were encountered: