markdown.vim 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. " Vim filetype plugin
  2. " Language: Markdown
  3. " Maintainer: Tim Pope <vimNOSPAM@tpope.org>
  4. " Last Change: 2016 Aug 29
  5. if exists("b:did_ftplugin")
  6. finish
  7. endif
  8. runtime! ftplugin/html.vim ftplugin/html_*.vim ftplugin/html/*.vim
  9. setlocal comments=fb:*,fb:-,fb:+,n:> commentstring=>\ %s
  10. setlocal formatoptions+=tcqln formatoptions-=r formatoptions-=o
  11. setlocal formatlistpat=^\\s*\\d\\+\\.\\s\\+\\\|^[-*+]\\s\\+\\\|^\\[^\\ze[^\\]]\\+\\]:
  12. if exists('b:undo_ftplugin')
  13. let b:undo_ftplugin .= "|setl cms< com< fo< flp<"
  14. else
  15. let b:undo_ftplugin = "setl cms< com< fo< flp<"
  16. endif
  17. function! MarkdownFold()
  18. let line = getline(v:lnum)
  19. " Regular headers
  20. let depth = match(line, '\(^#\+\)\@<=\( .*$\)\@=')
  21. if depth > 0
  22. return ">" . depth
  23. endif
  24. " Setext style headings
  25. let nextline = getline(v:lnum + 1)
  26. if (line =~ '^.\+$') && (nextline =~ '^=\+$')
  27. return ">1"
  28. endif
  29. if (line =~ '^.\+$') && (nextline =~ '^-\+$')
  30. return ">2"
  31. endif
  32. return "="
  33. endfunction
  34. if has("folding") && exists("g:markdown_folding")
  35. setlocal foldexpr=MarkdownFold()
  36. setlocal foldmethod=expr
  37. let b:undo_ftplugin .= " foldexpr< foldmethod<"
  38. endif
  39. " vim:set sw=2: