Skip to main content
deleted 116 characters in body
Source Link
Rich
  • 32.6k
  • 4
  • 74
  • 141

I wasn't able to find a reasonable solution that works by augmenting the existing highlighting, so instead you're going to haveOne approach is to overwriteoverwrite the existing markdownLinkText syntax item with one that conceals the [ and ] delimiters:

This item is currently defined with the following line from $VIMRUNTIME/syntax/markdown.vim (line continuations added by me for Stack Exchange formatting purposes):

syn region markdownLinkText matchgroup=markdownLinkTextDelimiter
    \ start="!\=\[\%(\_[^]]*]\%( \=[[(]\)\)\@=" end="\]\%( \=[[(]\)\@="
    \ nextgroup=markdownLink,markdownId skipwhite
    \ contains=@markdownInline,markdownLineStart

This highlights the ends of the region (i.e. the [ and ] delimiters) with the markdownLinkTextDelimiter group via matchgroup. To instead make it conceal them, tack concealends onto the end:

syn region markdownLinkText matchgroup=markdownLinkTextDelimiter
    \ start="!\=\[\%(\_[^]]*]\%( \=[[(]\)\)\@=" end="\]\%( \=[[(]\)\@="
    \ nextgroup=markdownLink,markdownId skipwhite
    \ contains=@markdownInline,markdownLineStart
    \ concealends

The downside of this approach is that if the existing syntax definition is altered to handle more cases, then you may need to update your tweaked version, too. I'm guessing the markdown link syntax is reasonably stable at this point, so hopefully this will work well for you.

This will take precedence over the existing item so long as it is defined later, so putting it .vim/after/syntax/markdown.vim is the best place for it. (Putting it in a FileType autocommand should work too, but there are caveats.)

I wasn't able to find a reasonable solution that works by augmenting the existing highlighting, so instead you're going to have to overwrite the existing markdownLinkText syntax item with one that conceals the [ and ] delimiters:

This item is currently defined with the following line from $VIMRUNTIME/syntax/markdown.vim (line continuations added by me for Stack Exchange formatting purposes):

syn region markdownLinkText matchgroup=markdownLinkTextDelimiter
    \ start="!\=\[\%(\_[^]]*]\%( \=[[(]\)\)\@=" end="\]\%( \=[[(]\)\@="
    \ nextgroup=markdownLink,markdownId skipwhite
    \ contains=@markdownInline,markdownLineStart

This highlights the ends of the region (i.e. the [ and ] delimiters) with the markdownLinkTextDelimiter group via matchgroup. To instead make it conceal them, tack concealends onto the end:

syn region markdownLinkText matchgroup=markdownLinkTextDelimiter
    \ start="!\=\[\%(\_[^]]*]\%( \=[[(]\)\)\@=" end="\]\%( \=[[(]\)\@="
    \ nextgroup=markdownLink,markdownId skipwhite
    \ contains=@markdownInline,markdownLineStart
    \ concealends

The downside of this approach is that if the existing syntax definition is altered to handle more cases, then you may need to update your tweaked version, too. I'm guessing the markdown link syntax is reasonably stable at this point, so hopefully this will work well for you.

This will take precedence over the existing item so long as it is defined later, so putting it .vim/after/syntax/markdown.vim is the best place for it. (Putting it in a FileType autocommand should work too, but there are caveats.)

One approach is to overwrite the existing markdownLinkText syntax item with one that conceals the [ and ] delimiters:

This item is currently defined with the following line from $VIMRUNTIME/syntax/markdown.vim (line continuations added by me for Stack Exchange formatting purposes):

syn region markdownLinkText matchgroup=markdownLinkTextDelimiter
    \ start="!\=\[\%(\_[^]]*]\%( \=[[(]\)\)\@=" end="\]\%( \=[[(]\)\@="
    \ nextgroup=markdownLink,markdownId skipwhite
    \ contains=@markdownInline,markdownLineStart

This highlights the ends of the region (i.e. the [ and ] delimiters) with the markdownLinkTextDelimiter group via matchgroup. To instead make it conceal them, tack concealends onto the end:

syn region markdownLinkText matchgroup=markdownLinkTextDelimiter
    \ start="!\=\[\%(\_[^]]*]\%( \=[[(]\)\)\@=" end="\]\%( \=[[(]\)\@="
    \ nextgroup=markdownLink,markdownId skipwhite
    \ contains=@markdownInline,markdownLineStart
    \ concealends

The downside of this approach is that if the existing syntax definition is altered to handle more cases, then you may need to update your tweaked version, too. I'm guessing the markdown link syntax is reasonably stable at this point, so hopefully this will work well for you.

This will take precedence over the existing item so long as it is defined later, so putting it .vim/after/syntax/markdown.vim is the best place for it. (Putting it in a FileType autocommand should work too, but there are caveats.)

Source Link
Rich
  • 32.6k
  • 4
  • 74
  • 141

I wasn't able to find a reasonable solution that works by augmenting the existing highlighting, so instead you're going to have to overwrite the existing markdownLinkText syntax item with one that conceals the [ and ] delimiters:

This item is currently defined with the following line from $VIMRUNTIME/syntax/markdown.vim (line continuations added by me for Stack Exchange formatting purposes):

syn region markdownLinkText matchgroup=markdownLinkTextDelimiter
    \ start="!\=\[\%(\_[^]]*]\%( \=[[(]\)\)\@=" end="\]\%( \=[[(]\)\@="
    \ nextgroup=markdownLink,markdownId skipwhite
    \ contains=@markdownInline,markdownLineStart

This highlights the ends of the region (i.e. the [ and ] delimiters) with the markdownLinkTextDelimiter group via matchgroup. To instead make it conceal them, tack concealends onto the end:

syn region markdownLinkText matchgroup=markdownLinkTextDelimiter
    \ start="!\=\[\%(\_[^]]*]\%( \=[[(]\)\)\@=" end="\]\%( \=[[(]\)\@="
    \ nextgroup=markdownLink,markdownId skipwhite
    \ contains=@markdownInline,markdownLineStart
    \ concealends

The downside of this approach is that if the existing syntax definition is altered to handle more cases, then you may need to update your tweaked version, too. I'm guessing the markdown link syntax is reasonably stable at this point, so hopefully this will work well for you.

This will take precedence over the existing item so long as it is defined later, so putting it .vim/after/syntax/markdown.vim is the best place for it. (Putting it in a FileType autocommand should work too, but there are caveats.)