My dotfiles. Period.

mkd.vim 5.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. " Vim syntax file
  2. " Language: Markdown
  3. " Maintainer: Ben Williams <benw@plasticboy.com>
  4. " URL: http://plasticboy.com/markdown-vim-mode/
  5. " Version: 9
  6. " Last Change: 2009 May 18
  7. " Remark: Uses HTML syntax file
  8. " Remark: I don't do anything with angle brackets (<>) because that would too easily
  9. " easily conflict with HTML syntax
  10. " TODO: Handle stuff contained within stuff (e.g. headings within blockquotes)
  11. " Read the HTML syntax to start with
  12. if version < 600
  13. so <sfile>:p:h/html.vim
  14. else
  15. runtime! syntax/html.vim
  16. unlet b:current_syntax
  17. endif
  18. if version < 600
  19. syntax clear
  20. elseif exists("b:current_syntax")
  21. finish
  22. endif
  23. " don't use standard HiLink, it will not work with included syntax files
  24. if version < 508
  25. command! -nargs=+ HtmlHiLink hi link <args>
  26. else
  27. command! -nargs=+ HtmlHiLink hi def link <args>
  28. endif
  29. syn spell toplevel
  30. syn case ignore
  31. syn sync linebreaks=1
  32. "additions to HTML groups
  33. syn region htmlItalic start="\\\@<!\*\S\@=" end="\S\@<=\\\@<!\*" keepend oneline
  34. syn region htmlItalic start="\(^\|\s\)\@<=_\|\\\@<!_\([^_]\+\s\)\@=" end="\S\@<=_\|_\S\@=" keepend oneline
  35. syn region htmlBold start="\S\@<=\*\*\|\*\*\S\@=" end="\S\@<=\*\*\|\*\*\S\@=" keepend oneline
  36. syn region htmlBold start="\S\@<=__\|__\S\@=" end="\S\@<=__\|__\S\@=" keepend oneline
  37. syn region htmlBoldItalic start="\S\@<=\*\*\*\|\*\*\*\S\@=" end="\S\@<=\*\*\*\|\*\*\*\S\@=" keepend oneline
  38. syn region htmlBoldItalic start="\S\@<=___\|___\S\@=" end="\S\@<=___\|___\S\@=" keepend oneline
  39. " [link](URL) | [link][id] | [link][]
  40. syn region mkdFootnotes matchgroup=mkdDelimiter start="\[^" end="\]"
  41. syn region mkdID matchgroup=mkdDelimiter start="\[" end="\]" contained oneline
  42. syn region mkdURL matchgroup=mkdDelimiter start="(" end=")" contained oneline
  43. syn region mkdLink matchgroup=mkdDelimiter start="\\\@<!\[" end="\]\ze\s*[[(]" contains=@Spell nextgroup=mkdURL,mkdID skipwhite oneline
  44. " mkd inline links: protocol optional user:pass@ sub/domain .com, .co.uk, etc optional port path/querystring/hash fragment
  45. " ------------ _____________________ --------------------------- ________________________ ----------------- __
  46. syntax match mkdInlineURL /https\?:\/\/\(\w\+\(:\w\+\)\?@\)\?\([A-Za-z][-_0-9A-Za-z]*\.\)\{1,}\(\w\{2,}\.\?\)\{1,}\(:[0-9]\{1,5}\)\?\S*/
  47. " Link definitions: [id]: URL (Optional Title)
  48. " TODO handle automatic links without colliding with htmlTag (<URL>)
  49. syn region mkdLinkDef matchgroup=mkdDelimiter start="^ \{,3}\zs\[" end="]:" oneline nextgroup=mkdLinkDefTarget skipwhite
  50. syn region mkdLinkDefTarget start="<\?\zs\S" excludenl end="\ze[>[:space:]\n]" contained nextgroup=mkdLinkTitle,mkdLinkDef skipwhite skipnl oneline
  51. syn region mkdLinkTitle matchgroup=mkdDelimiter start=+"+ end=+"+ contained
  52. syn region mkdLinkTitle matchgroup=mkdDelimiter start=+'+ end=+'+ contained
  53. syn region mkdLinkTitle matchgroup=mkdDelimiter start=+(+ end=+)+ contained
  54. "define Markdown groups
  55. syn match mkdLineContinue ".$" contained
  56. syn match mkdLineBreak / \+$/
  57. syn region mkdBlockquote start=/^\s*>/ end=/$/ contains=mkdLineBreak,mkdLineContinue,@Spell
  58. syn region mkdCode start=/\(\([^\\]\|^\)\\\)\@<!`/ end=/\(\([^\\]\|^\)\\\)\@<!`/
  59. syn region mkdCode start=/\s*``[^`]*/ end=/[^`]*``\s*/
  60. syn region mkdCode start=/^```\s*\w*\s*$/ end=/^```\s*$/
  61. syn region mkdCode start="<pre[^>]*>" end="</pre>"
  62. syn region mkdCode start="<code[^>]*>" end="</code>"
  63. syn region mkdFootnote start="\[^" end="\]"
  64. syn match mkdCode /^\s*\n\(\(\s\{4,}[^ ]\|\t\+[^\t]\).*\n\)\+/
  65. syn match mkdListItem "^\s*[-*+]\s\+"
  66. syn match mkdListItem "^\s*\d\+\.\s\+"
  67. syn match mkdRule /^\s*\*\s\{0,1}\*\s\{0,1}\*$/
  68. syn match mkdRule /^\s*-\s\{0,1}-\s\{0,1}-$/
  69. syn match mkdRule /^\s*_\s\{0,1}_\s\{0,1}_$/
  70. syn match mkdRule /^\s*-\{3,}$/
  71. syn match mkdRule /^\s*\*\{3,5}$/
  72. "HTML headings
  73. syn region htmlH1 start="^\s*#" end="\($\|#\+\)" contains=@Spell
  74. syn region htmlH2 start="^\s*##" end="\($\|#\+\)" contains=@Spell
  75. syn region htmlH3 start="^\s*###" end="\($\|#\+\)" contains=@Spell
  76. syn region htmlH4 start="^\s*####" end="\($\|#\+\)" contains=@Spell
  77. syn region htmlH5 start="^\s*#####" end="\($\|#\+\)" contains=@Spell
  78. syn region htmlH6 start="^\s*######" end="\($\|#\+\)" contains=@Spell
  79. syn match htmlH1 /^.\+\n=\+$/ contains=@Spell
  80. syn match htmlH2 /^.\+\n-\+$/ contains=@Spell
  81. "highlighting for Markdown groups
  82. HtmlHiLink mkdString String
  83. HtmlHiLink mkdCode String
  84. HtmlHiLink mkdFootnote Comment
  85. HtmlHiLink mkdBlockquote Comment
  86. HtmlHiLink mkdLineContinue Comment
  87. HtmlHiLink mkdListItem Identifier
  88. HtmlHiLink mkdRule Identifier
  89. HtmlHiLink mkdLineBreak Todo
  90. HtmlHiLink mkdFootnotes htmlLink
  91. HtmlHiLink mkdLink htmlLink
  92. HtmlHiLink mkdURL htmlString
  93. HtmlHiLink mkdInlineURL htmlLink
  94. HtmlHiLink mkdID Identifier
  95. HtmlHiLink mkdLinkDef mkdID
  96. HtmlHiLink mkdLinkDefTarget mkdURL
  97. HtmlHiLink mkdLinkTitle htmlString
  98. HtmlHiLink mkdDelimiter Delimiter
  99. let b:current_syntax = "mkd"
  100. delcommand HtmlHiLink
  101. " vim: ts=8