vim-pandoc / vim-pandoc-syntax

pandoc markdown syntax, to be installed alongside vim-pandoc
MIT License
425 stars 61 forks source link

Trying to add vimwiki tags highlight group, conflict with pandocDefinitionBlock #364

Open lyndhurst opened 2 years ago

lyndhurst commented 2 years ago

Hi, I am trying to make pandoc-syntax play nice with vimwiki. Part of it would be to add some highlighting to Vimwiki tags. Which is defined in the help as

A tag is a sequence of non-space characters between two colons: :tag-example: It is allowed to concatenate multiple tags in one line: :tag-one:tag-two:

I simply got the regex from the vimwiki syntax file, and added to my .vimrc:

syn match myPandocWikiTags
                \ /\%(^\|\s\)\@<=:\%([^:[:space:]]\+:\)\+\%(\s\|$\)\@=/

It works fine except when I add a tag within the two first columns of a line, it turns the myPandocWikiTag into a pandocDefinitionBlock.

I suck at vimscript, and to make this task easier, at regex too :) With my little understanding, I imagine that the best course of action would be to redefine the pandocDefinitionBlock adding a rule to exclude any pattern where a second colon stands right after the first colon and any non space character.

Maybe I am wrong, and the vimwiki tag expression should be modified. Any help would be greatly appreciated, thanks.

I will paste the pandocDefinitionBlock expression from the syntax file below to make it easier for anyone who would like to help me to copy, and modify.

syn region pandocDefinitionBlock
    \ start=/^\%(\_^\s*\([`~]\)\1\{2,}\)\@!.*\n\(^\s*\n\)\=\s\{0,2}\([:~]\)\(\3\{2,}\3*\)\@!/
    \ skip=/\n\n\zs\s/
    \ end=/\n\n/
    \ contains=pandocDefinitionBlockMark,pandocDefinitionBlockTerm,pandocCodeBlockInsideIndent,pandocEmphasis,pandocStrong,pandocStrongEmphasis,pandocNoFormatted,pandocStrikeout,pandocSubscript,pandocSuperscript,pandocFootnoteID,pandocReferenceURL,pandocReferenceLabel,pandocLaTeXMathBlock,pandocLaTeXInlineMath,pandocEscapedDollar,pandocAutomaticLink,pandocEmDash,pandocEnDash,pandocFootnoteDef,pandocFootnoteBlock,pandocFootnoteID