From: martin f. krafft Date: Mon, 7 Apr 2014 15:59:32 +0000 (+0200) Subject: check in mediawiki syntax/ftplugin from wikipedia X-Git-Url: https://git.madduck.net/etc/vim.git/commitdiff_plain/478346e5e67aa5a184bf28fc8925e353536ca78d check in mediawiki syntax/ftplugin from wikipedia --- diff --git a/.vim/ftdetect/mediawiki.vim b/.vim/ftdetect/mediawiki.vim new file mode 100644 index 0000000..472801a --- /dev/null +++ b/.vim/ftdetect/mediawiki.vim @@ -0,0 +1,4 @@ +augroup filetypedetect + " detect mediawiki buffers + au! BufRead,BufNewFile *.mw setf mediawiki +augroup END diff --git a/.vim/ftplugin/mediawiki.vim b/.vim/ftplugin/mediawiki.vim new file mode 100644 index 0000000..c068d71 --- /dev/null +++ b/.vim/ftplugin/mediawiki.vim @@ -0,0 +1,51 @@ +" Many MediaWiki wikis prefer line breaks only at the end of paragraphs +" (like in a text processor), which results in long, wrapping lines. +setlocal wrap linebreak +setlocal textwidth=0 + +" No auto-wrap at all. +setlocal formatoptions-=tc formatoptions+=l +if v:version >= 602 | setlocal formatoptions-=a | endif + +" Make navigation more amenable to the long wrapping lines. +noremap k gk +noremap j gj +noremap gk +noremap gj +noremap 0 g0 +noremap ^ g^ +noremap $ g$ +noremap D dg$ +noremap C cg$ +noremap A g$a + +inoremap gk +inoremap gj + +" utf-8 should be set if not already done globally +setlocal fileencoding=utf-8 +setlocal matchpairs+=<:> + +" Treat lists, indented text and tables as comment lines and continue with the +" same formatting in the next line (i.e. insert the comment leader) when hitting +" or using "o". +setlocal comments=n:#,n:*,n:\:,s:{\|,m:\|,ex:\|} +setlocal formatoptions+=roq + +" match HTML tags (taken directly from $VIM/ftplugin/html.vim) +if exists("loaded_matchit") + let b:match_ignorecase=0 + let b:match_skip = 's:Comment' + let b:match_words = '<:>,' . + \ '<\@<=[ou]l\>[^>]*\%(>\|$\):<\@<=li\>:<\@<=/[ou]l>,' . + \ '<\@<=dl\>[^>]*\%(>\|$\):<\@<=d[td]\>:<\@<=/dl>,' . + \ '<\@<=\([^/][^ \t>]*\)[^>]*\%(>\|$\):<\@<=/\1>' +endif + +" Other useful mappings +" Insert a matching = automatically while starting a new header. +inoremap = =(getline('.')==''\|\|getline('.')=~'^=\+$')?"==\Left>":"=" + +" Enable folding based on ==sections== +setlocal foldexpr=getline(v:lnum)=~'^\\(=\\+\\)[^=]\\+\\1\\(\\s*\\)\\=\\s*$'?\">\".(len(matchstr(getline(v:lnum),'^=\\+'))-1):\"=\" +setlocal fdm=expr diff --git a/.vim/syntax/mediawiki.vim b/.vim/syntax/mediawiki.vim new file mode 100644 index 0000000..950b016 --- /dev/null +++ b/.vim/syntax/mediawiki.vim @@ -0,0 +1,293 @@ +" mediawiki.vim (formerly named Wikipedia.vim) +" +" Vim syntax file +" Language: MediaWiki, http://www.mediawiki.org/ +" Maintainer: This syntax file needs a maintainer in order to ship +" with Vim. Please contact [[User:Unforgettableid]] if you want +" to volunteer. +" Home: http://en.wikipedia.org/wiki/Wikipedia:Text_editor_support#Vim +" Last Change: 2011 Sep 19 +" Credits: [[User:Aepd87]], [[User:Danny373]], [[User:Ingo Karkat]], et al. +" +" Published on Wikipedia in 2003-04 and declared authorless. +" +" Based on the HTML syntax file. Probably too closely based, in fact. +" There may well be name collisions everywhere, but ignorance is bliss, +" so they say. +" +" To do: plug-in support for downloading and uploading to the server. + +if !exists("main_syntax") + if version < 600 + syntax clear + elseif exists("b:current_syntax") + finish + endif + let main_syntax = "html" +endif + +syntax case ignore +if v:version >= 700 + syntax spell toplevel +endif + +" Mark illegal characters +sy match htmlError "[<>&]" + +" Tags +sy region htmlString contained start=+"+ end=+"+ contains=htmlSpecialChar,@htmlPreproc +sy region htmlString contained start=+'+ end=+'+ contains=htmlSpecialChar,@htmlPreproc +sy match htmlValue contained "=[\t ]*[^'" \t>][^ \t>]*"hs=s+1 contains=@htmlPreproc +sy region htmlEndTag start=++ contains=htmlTagN,htmlTagError +sy region htmlTag start=+<[^/]+ end=+>+ contains=htmlTagN,htmlString,htmlArg,htmlValue,htmlTagError,htmlEvent,htmlCssDefinition,@htmlPreproc,@htmlArgCluster +sy match htmlTagN contained +<\s*[-a-zA-Z0-9]\++hs=s+1 contains=htmlTagName,htmlSpecialTagName,@htmlTagNameCluster +sy match htmlTagN contained +]<"ms=s+1 + +" Allowed HTML tag names +sy keyword htmlTagName contained big blockquote br caption center cite code +sy keyword htmlTagName contained dd del div dl dt font hr ins li +sy keyword htmlTagName contained ol p pre rb rp rt ruby s small span strike sub +sy keyword htmlTagName contained sup table td th tr tt ul var +sy match htmlTagName contained "\<\(b\|i\|u\|h[1-6]\|em\|strong\)\>" +" Allowed Wiki tag names +sy keyword htmlTagName contained math nowiki references source syntaxhighlight + +" Allowed arg names +sy keyword htmlArg contained align lang dir width height nowrap bgcolor clear +sy keyword htmlArg contained noshade cite datetime size face color type start +sy keyword htmlArg contained value compact summary border frame rules +sy keyword htmlArg contained cellspacing cellpadding valign char charoff +sy keyword htmlArg contained colgroup col span abbr axis headers scope rowspan +sy keyword htmlArg contained colspan id class name style title + +" Special characters +sy match htmlSpecialChar "&#\=[0-9A-Za-z]\{1,8};" + +" Comments +sy region htmlComment start=++ contains=htmlCommentPart,htmlCommentError +sy match htmlCommentError contained "[^>+ + +if !exists("html_no_rendering") + sy cluster htmlTop contains=@Spell,htmlTag,htmlEndTag,htmlSpecialChar,htmlPreProc,htmlComment,htmlLink,@htmlPreproc + + sy region htmlBold start="" end=""me=e-4 contains=@htmlTop,htmlBoldUnderline,htmlBoldItalic + sy region htmlBold start="" end=""me=e-9 contains=@htmlTop,htmlBoldUnderline,htmlBoldItalic + sy region htmlBoldUnderline contained start="" end=""me=e-4 contains=@htmlTop,htmlBoldUnderlineItalic + sy region htmlBoldItalic contained start="" end=""me=e-4 contains=@htmlTop,htmlBoldItalicUnderline + sy region htmlBoldItalic contained start="" end=""me=e-5 contains=@htmlTop,htmlBoldItalicUnderline + sy region htmlBoldUnderlineItalic contained start="" end=""me=e-4 contains=@htmlTop + sy region htmlBoldUnderlineItalic contained start="" end=""me=e-5 contains=@htmlTop + sy region htmlBoldItalicUnderline contained start="" end=""me=e-4 contains=@htmlTop,htmlBoldUnderlineItalic + + sy region htmlUnderline start="" end=""me=e-4 contains=@htmlTop,htmlUnderlineBold,htmlUnderlineItalic + sy region htmlUnderlineBold contained start="" end=""me=e-4 contains=@htmlTop,htmlUnderlineBoldItalic + sy region htmlUnderlineBold contained start="" end=""me=e-9 contains=@htmlTop,htmlUnderlineBoldItalic + sy region htmlUnderlineItalic contained start="" end=""me=e-4 contains=@htmlTop,htmlUnderlineItalicBold + sy region htmlUnderlineItalic contained start="" end=""me=e-5 contains=@htmlTop,htmlUnderlineItalicBold + sy region htmlUnderlineItalicBold contained start="" end=""me=e-4 contains=@htmlTop + sy region htmlUnderlineItalicBold contained start="" end=""me=e-9 contains=@htmlTop + sy region htmlUnderlineBoldItalic contained start="" end=""me=e-4 contains=@htmlTop + sy region htmlUnderlineBoldItalic contained start="" end=""me=e-5 contains=@htmlTop + + sy region htmlItalic start="" end=""me=e-4 contains=@htmlTop,htmlItalicBold,htmlItalicUnderline + sy region htmlItalic start="" end=""me=e-5 contains=@htmlTop + sy region htmlItalicBold contained start="" end=""me=e-4 contains=@htmlTop,htmlItalicBoldUnderline + sy region htmlItalicBold contained start="" end=""me=e-9 contains=@htmlTop,htmlItalicBoldUnderline + sy region htmlItalicBoldUnderline contained start="" end=""me=e-4 contains=@htmlTop + sy region htmlItalicUnderline contained start="" end=""me=e-4 contains=@htmlTop,htmlItalicUnderlineBold + sy region htmlItalicUnderlineBold contained start="" end=""me=e-4 contains=@htmlTop + sy region htmlItalicUnderlineBold contained start="" end=""me=e-9 contains=@htmlTop + + sy region htmlH1 start="" end=""me=e-5 contains=@htmlTop + sy region htmlH2 start="" end=""me=e-5 contains=@htmlTop + sy region htmlH3 start="" end=""me=e-5 contains=@htmlTop + sy region htmlH4 start="" end=""me=e-5 contains=@htmlTop + sy region htmlH5 start="" end=""me=e-5 contains=@htmlTop + sy region htmlH6 start="" end=""me=e-5 contains=@htmlTop +endif + + +" No htmlTop and wikiPre inside HTML preformatted areas, because +" MediaWiki renders everything in there literally (HTML tags and +" entities, too):
 tags work as the combination of  and
+" the standard HTML 
 tag: the content will preformatted, and it
+" will not be parsed, but shown as in the wikitext source.
+"
+" With wikiPre, indented lines would be rendered differently from
+" unindented lines.
+sy match htmlPreTag       /
/         contains=htmlTag
+sy match htmlPreEndTag    /<\/pre>/       contains=htmlEndTag
+sy match wikiNowikiTag    //      contains=htmlTag
+sy match wikiNowikiEndTag /<\/nowiki>/    contains=htmlEndTag
+sy match wikiSourceTag    /]\+>/ contains=htmlTag
+sy match wikiSourceEndTag /<\/source>/    contains=htmlEndTag
+sy match wikiSyntaxHLTag    /]\+>/ contains=htmlTag
+sy match wikiSyntaxHLEndTag /<\/syntaxhighlight>/    contains=htmlEndTag
+ 
+" Note: Cannot use 'start="
"rs=e', so still have the 
 tag
+" highlighted correctly via separate sy-match. Unfortunately, this will
+" also highlight 
 tags inside the preformatted region. 
+sy region htmlPre    start="
"                 end="<\/pre>"me=e-6    contains=htmlPreTag
+sy region wikiNowiki start=""              end="<\/nowiki>"me=e-9 contains=wikiNowikiTag
+sy region wikiSource start="]\+>"         keepend end="<\/source>"me=e-9 contains=wikiSourceTag
+sy region wikiSyntaxHL start="]\+>" keepend end="<\/syntaxhighlight>"me=e-18 contains=wikiSyntaxHLTag
+ 
+sy include @TeX syntax/tex.vim
+sy region wikiTeX matchgroup=htmlTag start="" end="<\/math>"  contains=@texMathZoneGroup,wikiNowiki,wikiNowikiEndTag
+sy region wikiRef matchgroup=htmlTag start=""  end="<\/ref>"   contains=wikiNowiki,wikiNowikiEndTag
+ 
+sy cluster wikiTop contains=@Spell,wikiLink,wikiNowiki,wikiNowikiEndTag
+ 
+sy region wikiItalic        start=+'\@
+else
+  command! -nargs=+ HtmlHiLink hi def link 
+endif
+ 
+if version >= 508 || !exists("did_html_syn_inits")
+  HtmlHiLink htmlTag            Function
+  HtmlHiLink htmlEndTag         Identifier
+  HtmlHiLink htmlArg            Type
+  HtmlHiLink htmlTagName        htmlStatement
+  HtmlHiLink htmlSpecialTagName Exception
+  HtmlHiLink htmlValue          String
+  HtmlHiLink htmlSpecialChar    Special
+ 
+  if !exists("html_no_rendering")
+    HtmlHiLink htmlTitle Title
+    HtmlHiLink htmlH1    htmlTitle
+    HtmlHiLink htmlH2    htmlTitle
+    HtmlHiLink htmlH3    htmlTitle
+    HtmlHiLink htmlH4    htmlTitle
+    HtmlHiLink htmlH5    htmlTitle
+    HtmlHiLink htmlH6    htmlTitle
+ 
+    HtmlHiLink htmlPreProc          PreProc
+    HtmlHiLink htmlHead             htmlPreProc
+    HtmlHiLink htmlPreProcAttrName  htmlPreProc
+    HtmlHiLink htmlPreStmt          htmlPreProc
+ 
+    HtmlHiLink htmlSpecial          Special
+    HtmlHiLink htmlCssDefinition    htmlSpecial
+    HtmlHiLink htmlEvent            htmlSpecial
+    HtmlHiLink htmlSpecialChar      htmlSpecial
+ 
+    HtmlHiLink htmlComment          Comment
+    HtmlHiLink htmlCommentPart      htmlComment
+    HtmlHiLink htmlCssStyleComment  htmlComment
+ 
+    HtmlHiLink htmlString           String
+    HtmlHiLink htmlPreAttr          htmlString
+    HtmlHiLink htmlValue            htmlString
+ 
+    HtmlHiLink htmlError            Error
+    HtmlHiLink htmlBadArg           htmlError
+    HtmlHiLink htmlBadTag           htmlError
+    HtmlHiLink htmlCommentError     htmlError
+    HtmlHiLink htmlPreError         htmlError  
+    HtmlHiLink htmlPreProcAttrError htmlError
+    HtmlHiLink htmlTagError         htmlError
+ 
+    HtmlHiLink htmlStatement        Statement
+ 
+    HtmlHiLink htmlConstant         Constant
+ 
+    HtmlHiLink htmlBoldItalicUnderline htmlBoldUnderlineItalic
+    HtmlHiLink htmlUnderlineItalicBold htmlBoldUnderlineItalic
+    HtmlHiLink htmlUnderlineBoldItalic htmlBoldUnderlineItalic
+    HtmlHiLink htmlItalicBoldUnderline htmlBoldUnderlineItalic
+    HtmlHiLink htmlItalicUnderlineBold htmlBoldUnderlineItalic
+ 
+    HtmlHiLink htmlItalicBold          htmlBoldItalic
+    HtmlHiLink htmlItalicUnderline     htmlUnderlineItalic
+    HtmlHiLink htmlUnderlineBold       htmlBoldUnderline
+ 
+    HtmlHiLink htmlLink Underlined
+ 
+    if !exists("html_my_rendering")
+      hi def htmlBold                term=bold                  cterm=bold                  gui=bold
+      hi def htmlBoldUnderline       term=bold,underline        cterm=bold,underline        gui=bold,underline
+      hi def htmlBoldItalic          term=bold,italic           cterm=bold,italic           gui=bold,italic
+      hi def htmlBoldUnderlineItalic term=bold,italic,underline cterm=bold,italic,underline gui=bold,italic,underline
+      hi def htmlUnderline           term=underline             cterm=underline             gui=underline
+      hi def htmlUnderlineItalic     term=italic,underline      cterm=italic,underline      gui=italic,underline
+      hi def htmlItalic              term=italic                cterm=italic                gui=italic
+    endif
+ 
+  endif " !exists("html_no_rendering")
+ 
+  if version < 508
+    let did_html_syn_inits = 1
+  endif
+ 
+endif " version >= 508 || !exists("did_html_syn_inits")
+ 
+" Wiki highlighting
+ 
+HtmlHiLink wikiItalic        htmlItalic
+HtmlHiLink wikiBold          htmlBold
+HtmlHiLink wikiBoldItalic    htmlBoldItalic
+HtmlHiLink wikiItalicBold    htmlBoldItalic
+HtmlHiLink wikiBoldAndItalic htmlBoldItalic
+ 
+HtmlHiLink wikiH1 htmlTitle
+HtmlHiLink wikiH2 htmlTitle
+HtmlHiLink wikiH3 htmlTitle
+HtmlHiLink wikiH4 htmlTitle
+HtmlHiLink wikiH5 htmlTitle
+HtmlHiLink wikiH6 htmlTitle
+ 
+HtmlHiLink wikiLink           htmlLink
+HtmlHiLink wikiTemplate       htmlSpecial
+HtmlHiLink wikiParaFormatChar htmlSpecial
+HtmlHiLink wikiPre            htmlConstant
+HtmlHiLink wikiRef            htmlComment
+ 
+HtmlHiLink wikiSource         wikiPre
+HtmlHiLink wikiSyntaxHL       wikiPre
+ 
+ 
+let b:current_syntax = "html"
+ 
+delcommand HtmlHiLink
+ 
+if main_syntax == "html"
+  unlet main_syntax
+endif
+ 
+" vim: set et sts=2 sw=2: