mediawiki.vim 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. " Language: MediaWiki
  2. " Maintainer: Avid Seeker <avidseeker7@protonmail.com>
  3. " Home: http://en.wikipedia.org/wiki/Wikipedia:Text_editor_support#Vim
  4. " Last Change: 2024 Jul 14
  5. " Credits: chikamichi
  6. "
  7. if exists("b:did_ftplugin")
  8. finish
  9. endif
  10. let b:did_ftplugin = 1
  11. " Many MediaWiki wikis prefer line breaks only at the end of paragraphs
  12. " (like in a text processor), which results in long, wrapping lines.
  13. setlocal wrap linebreak
  14. setlocal textwidth=0
  15. setlocal formatoptions-=tc formatoptions+=l formatoptions+=roq
  16. setlocal matchpairs+=<:>
  17. " Treat lists, indented text and tables as comment lines and continue with the
  18. " same formatting in the next line (i.e. insert the comment leader) when hitting
  19. " <CR> or using "o".
  20. setlocal comments=n:#,n:*,n:\:,s:{\|,m:\|,ex:\|},s:<!--,m:\ \ \ \ ,e:-->
  21. setlocal commentstring=<!--\ %s\ -->
  22. " match HTML tags (taken directly from $VIM/ftplugin/html.vim)
  23. if exists("loaded_matchit")
  24. let b:match_ignorecase=0
  25. let b:match_skip = 's:Comment'
  26. let b:match_words = '<:>,' .
  27. \ '<\@<=[ou]l\>[^>]*\%(>\|$\):<\@<=li\>:<\@<=/[ou]l>,' .
  28. \ '<\@<=dl\>[^>]*\%(>\|$\):<\@<=d[td]\>:<\@<=/dl>,' .
  29. \ '<\@<=\([^/][^ \t>]*\)[^>]*\%(>\|$\):<\@<=/\1>'
  30. endif
  31. " Enable folding based on ==sections==
  32. setlocal foldexpr=getline(v:lnum)=~'^\\(=\\+\\)[^=]\\+\\1\\(\\s*<!--.*-->\\)\\=\\s*$'?\">\".(len(matchstr(getline(v:lnum),'^=\\+'))-1):\"=\"
  33. setlocal foldmethod=expr
  34. let b:undo_ftplugin = "setl commentstring< comments< formatoptions< foldexpr< foldmethod<"
  35. let b:undo_ftplugin += " matchpairs< linebreak< wrap< textwidth<"