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

Alone [ in command with @ confuses highlight #2094

Closed
Rmano opened this issue Jul 9, 2021 · 5 comments
Closed

Alone [ in command with @ confuses highlight #2094

Rmano opened this issue Jul 9, 2021 · 5 comments

Comments

@Rmano
Copy link

Rmano commented Jul 9, 2021

In (very rare) cases you have a command using \@ifnextchar (from the LaTeX kernel routines). When the checked char is [, the syntax highlighter got confused:

\documentclass{article}
\makeatletter
\def\something{\@ifnextchar[{\addtunablearrow@full}{\addtunablearrow@simple}}%
\makeatother

\begin{document}

Normal text here

\end{document}

image

Using this minimal vimrc:

set nocompatible
let &rtp  = '~/.vim/plugged/vimtex,' . &rtp
let &rtp .= ',~/.vim/plugged/vimtex/after'
filetype plugin indent on
syntax enable

Now --- this is a very special case, I know, so it's not high-priority at all. Is there a way to "reset" it? (adding a comment with %] does not suffice...)

Output from VimtexInfo

  base: open-square.tex
  root: /home/romano/software/bugs/vimtex
  tex: /home/romano/software/bugs/vimtex/open-square.tex
  out: 
  log: 
  aux: 
  fls: 
  main parser: current file verified
  compiler: latexmk
    configuration: 
      continuous: 1
      callback: 1
      latexmk options:
        -verbose
        -file-line-error
        -synctex=1
        -interaction=nonstopmode
      latexmk engine: -pdf
  viewer: General
  qf: LaTeX logfile
    addqflist: 51
    fix_paths: 52
    set_errorformat: 50
  document class: article
lervag added a commit that referenced this issue Jul 9, 2021
@lervag
Copy link
Owner

lervag commented Jul 9, 2021

I added support for \@ifnextchar. Seems cheap and simple, so why not. :)

@lervag lervag closed this as completed Jul 9, 2021
@Rmano
Copy link
Author

Rmano commented Jul 9, 2021

I hope I haven't been guilty of not specifying enough, but there is a series of "ifnextchar" --- the other one I use quite a lot is \pgfutil@ifnextchar. Maybe checking for "\ whatever @ifnextchar" would be better...

(Sorry, should have been clearer)

@lervag
Copy link
Owner

lervag commented Jul 9, 2021

... there is a series of "ifnextchar" --- the other one I use quite a lot is \pgfutil@ifnextchar. Maybe checking for "\ whatever @ifnextchar" would be better...

Ok; perhaps you could provide some reference to the command or family of commands? It is trivial to support \*@ifnextchar, of course, so I'll push that asap. But it would be good to understand the source a little bit better.

lervag added a commit that referenced this issue Jul 9, 2021
@Rmano
Copy link
Author

Rmano commented Jul 9, 2021

Yes --- these are commands to "generate" the optional argument in LaTeX (pre-latex3), you can see it there: https://www.texdev.net/2020/08/20/newdocumentcommand-versus-newcommand-versus.

When using packages that are multi-format (ie, that should work in LaTeX, TeX and ConTeXt) normally the package provides a wrapper, like for example \pgfutil@ifnextchar that I use in circuitikz. I know only about these two version, though, for now.

@lervag
Copy link
Owner

lervag commented Jul 9, 2021

Ok, thanks for the explanation. IIUC, my last commit then resolves the issue for you?

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

No branches or pull requests

2 participants