Skip to content

Feature: Conceal support for \cite commands#2002

Closed
lervag wants to merge 2 commits intomasterfrom
feat/syntax-cite-conceal
Closed

Feature: Conceal support for \cite commands#2002
lervag wants to merge 2 commits intomasterfrom
feat/syntax-cite-conceal

Conversation

@lervag
Copy link
Copy Markdown
Owner

@lervag lervag commented Mar 22, 2021

See #1965 for the current discussion.

@lervag lervag force-pushed the feat/syntax-cite-conceal branch from 5a9e656 to 9804764 Compare March 24, 2021 21:25
@whisperity
Copy link
Copy Markdown

I think it is great! 🏆

Screenshot_20210325_100729

(Please ignore the ugly white-ish background around concealed symbols, it's something that is broken in my (N)Vim and is irrespective of the plugin itself. Even C++ conceals are broken. 😦 )

@lervag
Copy link
Copy Markdown
Owner Author

lervag commented Mar 25, 2021

I think it is great!

Thanks!

One comment to your text: You should be aware of \citet{...} - don't write the author name + "et al" manually. :)

(Please ignore the ugly white-ish background around concealed symbols, it's something that is broken in my (N)Vim and is irrespective of the plugin itself. Even C++ conceals are broken. frowning )

The background is controlled by the Conceal highlight group. You should read :help hl-Conceal.

Open question: What should the default configuration be? I think we should keep it enabled by default, but with the type set to brackets. Agreed?

@whisperity
Copy link
Copy Markdown

One comment to your text: You should be aware of \citet{...} - don't write the author name + "et al" manually. :)

This is an older and already published paper, which uses IEEEtran template. \citet is a natbib command which isn't available there, I think.
It is also usual with numbered citations that you do not keep the author and the cite number together, i.e. things like

Pearsson and Fitch discussed that horses are brown [8].

(Please ignore the ugly white-ish background around concealed symbols, it's something that is broken in my (N)Vim and is irrespective of the plugin itself. Even C++ conceals are broken. frowning )

The background is controlled by the Conceal highlight group. You should read :help hl-Conceal.

Yeah, figured that, and this only happens with one particular colour scheme I am using, which is older than the conceal feature itself. There definitely isn't any conceal setting in the theme file, so now I'm trying to hunt down which other Vim plugin I use set the style... It's set to some odd value: ctermfg=7 ctermbg=242... And not by the theme file. Must be a link somewhere.

Open question: What should the default configuration be? I think we should keep it enabled by default, but with the type set to brackets. Agreed?

Yeah, enabled, and maybe instead of the emoji the bracketed one is better.

@lervag
Copy link
Copy Markdown
Owner Author

lervag commented Mar 25, 2021

The background is controlled by the Conceal highlight group. You should read :help hl-Conceal.

Yeah, figured that, and this only happens with one particular colour scheme I am using, which is older than the conceal feature itself. There definitely isn't any conceal setting in the theme file, so now I'm trying to hunt down which other Vim plugin I use set the style... It's set to some odd value: ctermfg=7 ctermbg=242... And not by the theme file. Must be a link somewhere.

You should read this gist by romainl; essentially:

augroup MyColors
  autocmd!
  autocmd ColorScheme * highlight Conceal ...
augroup END

Comment on lines +2100 to +2101
'icon' `\cite{x}` `📖`
'brackets' `\cite{x}` `[x]`
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Maybe it would be worth our while to replace x with xyz and show that the "brackets" concealment still shows the full key that's in there (as opposed to replacing \cite{arbitrary_long_identifier} with just [x].

lervag added a commit that referenced this pull request Mar 25, 2021
lervag added a commit that referenced this pull request Mar 25, 2021
@lervag lervag closed this Mar 25, 2021
@lervag lervag deleted the feat/syntax-cite-conceal branch March 25, 2021 21:29
@mawkler
Copy link
Copy Markdown

mawkler commented Mar 25, 2021

Looks great! Maybe it's too late now since you just merged this PR, but the only feedback I have is that perhaps 'brackets' should be the default value since it's less intrusive. Personally though I'll probably be using 'icon' :)

@lervag
Copy link
Copy Markdown
Owner Author

lervag commented Mar 25, 2021

'brackets' is the default value :)

@lervag
Copy link
Copy Markdown
Owner Author

lervag commented Mar 25, 2021

... Maybe it's too late now ...

And it's never too late :)

@postylem
Copy link
Copy Markdown
Contributor

postylem commented Mar 26, 2021

Great new feature! But I think it may be causing an issue (or there is one that is just coincidentally revealed here).

When there is a concealed citation inside of another command like \something{...\cite{xxx}} the syntax highlighting marks the closing brace as an error.

Screen Shot 2021-03-26 at 02 28 50

When the cite concealing is turned off, withlet g:vimtex_syntax_conceal_default=0 (or, equivalently, setting the cites key to 0, in g:vimtex_syntax_conceal_default), it doesn't show this highlighting error:

Screen Shot 2021-03-26 at 02 29 58

Interestingly, the issue doesn't arise with the icon style concealment.

Screen Shot 2021-03-26 at 02 42 51

These screenshots are on terminal Vim 8.2.2576 on macOS 11.2.3. I also found the same behaviour with neovim (0.5.0).

@lervag
Copy link
Copy Markdown
Owner Author

lervag commented Mar 26, 2021

Great new feature! But I think it may be causing an issue (or there is one that is just coincidentally revealed here).

Sorry about that, I think it is fixed now! :)

@mawkler
Copy link
Copy Markdown

mawkler commented Mar 26, 2021

'brackets' is the default value :)

Oh you're right, my bad!

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.

4 participants