This commit is contained in:
Adam Stankiewicz
2022-04-30 15:07:33 +02:00
parent 36a2bf60ad
commit 38282d5838
8 changed files with 223 additions and 16 deletions

View File

@@ -15,7 +15,7 @@ set cpoptions&vim
" Set the commentstring
setlocal commentstring=//%s
let b:undo_ftplugin = ' commentstring<'
let b:undo_ftplugin = 'setlocal commentstring<'
let &cpoptions = s:cpo_save
unlet s:cpo_save

View File

@@ -792,7 +792,7 @@ function! s:MarkdownHighlightSources(force)
" Look for code blocks in the current file
let filetypes = {}
for line in getline(1, '$')
let ft = matchstr(line, '```\s*\zs[0-9A-Za-z_+-]*\ze.*')
let ft = matchstr(line, '\(`\{3,}\|\~\{3,}\)\s*\zs[0-9A-Za-z_+-]*\ze.*')
if !empty(ft) && ft !~# '^\d*$' | let filetypes[ft] = 1 | endif
endfor
if !exists('b:mkd_known_filetypes')
@@ -823,8 +823,10 @@ function! s:MarkdownHighlightSources(force)
else
let include = '@' . toupper(filetype)
endif
let command = 'syntax region %s matchgroup=%s start="^\s*```\s*%s.*$" matchgroup=%s end="\s*```$" keepend contains=%s%s'
execute printf(command, group, startgroup, ft, endgroup, include, has('conceal') && get(g:, 'vim_markdown_conceal', 1) && get(g:, 'vim_markdown_conceal_code_blocks', 1) ? ' concealends' : '')
let command_backtick = 'syntax region %s matchgroup=%s start="^\s*`\{3,}\s*%s.*$" matchgroup=%s end="\s*`\{3,}$" keepend contains=%s%s'
let command_tilde = 'syntax region %s matchgroup=%s start="^\s*\~\{3,}\s*%s.*$" matchgroup=%s end="\s*\~\{3,}$" keepend contains=%s%s'
execute printf(command_backtick, group, startgroup, ft, endgroup, include, has('conceal') && get(g:, 'vim_markdown_conceal', 1) && get(g:, 'vim_markdown_conceal_code_blocks', 1) ? ' concealends' : '')
execute printf(command_tilde, group, startgroup, ft, endgroup, include, has('conceal') && get(g:, 'vim_markdown_conceal', 1) && get(g:, 'vim_markdown_conceal_code_blocks', 1) ? ' concealends' : '')
execute printf('syntax cluster mkdNonListItem add=%s', group)
let b:mkd_known_filetypes[ft] = 1