All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@git.madduck.net.
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
1 " Converts a markdown language (```foo) to the corresponding Vim filetype
2 function! s:get_vim_filetype(lang_markdown) abort
3 " If the user hasn't customised markdown fenced languages, just return the
5 if !exists('g:markdown_fenced_languages')
9 " Otherwise, check if it has an entry for the given language
10 for l:type in g:markdown_fenced_languages
11 let l:vim_type = substitute(matchstr(l:type, '[^=]*$'), '\..*', '', '')
12 let l:markdown_type = matchstr(l:type, '[^=]*')
14 if l:markdown_type ==# a:lang_markdown
21 return a:lang_markdown
24 function! s:do_highlight() abort
25 if exists('b:lsp_syntax_highlights')
26 for l:entry in b:lsp_syntax_highlights
27 let l:line = l:entry['line']
28 let l:lang = l:entry['language']
29 let l:ft = s:get_vim_filetype(l:lang)
31 execute printf('syntax match markdownHighlight%s contains=@markdownHighlight%s /^\%%%sl.*$/', l:ft, l:ft, l:line)
36 function! s:cleanup_markdown() abort
37 " Don't highlight _ in words
38 syntax match markdownError "\w\@<=\w\@="
40 " Conceal escaped characters
41 " Workaround for: https://github.com/palantir/python-language-server/issues/386
43 for l:escaped_char in ['`', '*', '_', '{', '}', '(', ')', '<', '>', '#', '+', '.', '!', '-']
44 execute printf('syntax region vimLspMarkdownEscape matchgroup=Conceal start="\\\ze[%s]" end="[%s]\zs" concealends', l:escaped_char, l:escaped_char)
50 call s:cleanup_markdown()