vim-pandoc-syntax
vim-pandoc-syntax copied to clipboard
Latex within \begin{...} environments not concealed
Here's a quick example of what I'm looking at:
Here, the inline \begin{align*} ... \end{align*}
is valid Pandoc syntax for embedded Latex, and it looks like syntax highlighting is applied but not the concealing.
(I've copied the same line down to 158 and surrounded it with $ ... $, which shows how it's concealed elsewhere.)
Incidentally, the underscores seem to be highlighted as spelling mistakes -- if there's a known way to disable spell-checking within those environments, please let me know!
I haven't looked into specifics but off the top of my head this is probably something we won't actually "fix" because fixing it would break more situations than it repairs. I can understand in your example why you would want conceal to work, but I can also imagine far more situations where messing with conceals inside a block of LaTeX that we can't fully parse is probably a really bad idea.
Seems reasonable, although I'd be perfectly happy in my case to blindly apply syntax highlighting/concealing to the special case of anything between (e.g.) \begin{align} and \end{align}.
If this is something that would be considered for the project, do you have any ideas for how this might be done? (I'd be fine with just branching for my particular use case.)
I'd be happy to allow this as part of the main plugin behind a (default off) option flag. It's probably just a matter of finding the syntax groups in question and noting what other groups or features are allowed inside that. We're clearly already finding the LaTeX block, so you just need to allow other things inside that.
@dzackgarza did you prehaps find a fix/workaround for the \begin{align}
and \end{align}
case?
@avivrosenberg Unfortunately not, and I don't quite know enough to figure out how to patch it in either! I imagine this must be taken care of in some other latex-specific plugins, but I couldn't find any good references to go off of.
Surprising, conceal works inside an eqnarray
. This suggets it's only a matter of allowing the right environment.
Update:
This seems to work because eqnarray
is a standard LaTeX environment and has an ad-hoc highlight match group in tex.vim. So here's a trick, do
:call TexNewMathZone("D", "align", 1)
:call TexNewMathZone("E", "align*", 1)
Now conceal should work in align
and align*
as well.
One cool trick that I lack the knowledge to implement would be figuring out how to use vimtex's more comprehensive syntax instead of the default.
Vimtex supports align
/align*
under texMathZoneAmsA
/texMathZoneAmsAS
respectively.
For now, I just switch back and forth between the filetypes.
@0az I think the easiest way to do it would be to change
syn include @LATEX syntax/tex.vim
in the syntax file so it points to vimtex's syntax file. Haven't tested it though. If it works, we could try checking if the file exists and using that conditionally.
Being able to use vimtex's syntax highlighting would be really helpful. Is there an easy way to do this manually?
My attempt to use vimtex(>=2.0)'s syntax: https://github.com/tomtomjhj/vim-pandoc-syntax/commit/ddb948fddf3ef602abe97e8e8d4931c03199aed7