I have a few custom LaTeX commands like this one, for instance:
\newcommand{\oeuvre}[1]{\textit{#1}}
I use this for titles of books and other works. Sometimes I want them to be italicized, sometimes I want them to be in quotes, so I just use this command and I can change it all at once when necessary.
Now I want Vim to highlight that command and its contents as it does with \emph
or \textit
, and I want to disable spelling inside it.
(So in \oeuvre{whatver}
"oeuvre" should be highlighted the same way as "emph" or "textit", and "whatver" should be in italics and it shouldn't count as a spelling mistake.)
Based on Vim's default TeX highlighting file, I tried this in my after/syntax/tex.vim
:
syn match texTypeStyle "\\oeuvre\>"
syn region texOeuvreStyle matchgroup=texTypeStyle start="\\oeuvre\s*{" matchgroup=texTypeStyle end="}" concealends contains=@texItalGroup,@NoSpell
hi texOeuvreStyle gui=italic cterm=italic
But it doesn't work. The command itself is highlighted properly, but not its contents, and spelling is still enabled.
So how can I get that to work?
(I know there are similar questions here, but I couldn't adapt them to my needs, I find this syntax highlighting stuff really confusing, sorry.)
Edit: Ok, I figured out that if I use syn region texItalStyle
it'll work like I want it to… I'm still curious as to why I can't define my own texOeuvreStyle
in what seems to me is the same way it's done for texItalStyle
in the default syntax file though.