|
I use Markdown to write blogs and recently I'm planning to utilize blockquotes (lines that start with Normally blockquotes are just completely grayed out for me, as their highlight group is linked to
|
Replies: 2 comments 14 replies
|
If you use Treesitter, then VimTeX syntax highlighting is simply not compatible. That is, to my knowledge, you can't use regular built-in (legacy) Vim/Neovim syntax rules in a nested fashion when you use Treesitter for your highlighting. If you want to use VimTeX for highlighting in Markdown, then you need to use the legacy syntax method for Markdown and specify rules with nested highlighting that includes tex highlighiting. This means you need to avoid enabling Treesitter for Markdown (at least for highlighting). Exactly how to do it depends on whether you are using a plugin (like vim-markdown) or not. For vim-markdown, you could add if exists('b:did_after_syntax_markdown') | finish | endif
let b:did_after_syntax_markdown = 1
syntax region mkdBlockquote start=/^\s*>/ end=/^\s*$/
\ contains=mkdLink,mkdInlineURL,mkdLineBreak,@Spell,mkdMath |
|
Recently I migrated to Lazy and the script above stopped working for some reason. Removing the first two lines makes it work again: if exists('b:did_after_syntax_markdown') | finish | endif
let b:did_after_syntax_markdown = 1But why exactly does this happen and is it safe to proceed without these two lines? Aren't they for preventing the script from being executed multiple times? |

If you use Treesitter, then VimTeX syntax highlighting is simply not compatible. That is, to my knowledge, you can't use regular built-in (legacy) Vim/Neovim syntax rules in a nested fashion when you use Treesitter for your highlighting.
If you want to use VimTeX for highlighting in Markdown, then you need to use the legacy syntax method for Markdown and specify rules with nested highlighting that includes tex highlighiting. This means you need to avoid enabling Treesitter for Markdown (at least for highlighting).
Exactly how to do it depends on whether you are using a plugin (like vim-markdown) or not. For vim-markdown, you could add
after/syntax/tex.vimwith something like this: