]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blob - doc/tips/vim_syntax_highlighting/ikiwiki.vim
Reanimate some of my URLs.
[git.ikiwiki.info.git] / doc / tips / vim_syntax_highlighting / ikiwiki.vim
1 " Vim syntax file
2 " Language:     Ikiwiki (links)
3 " Maintainer:   Recai Oktaş (roktasATdebian.org)
4 " Last Change:  2007 May 29
6 " Instructions:
7 "               - make sure to use the relevant syntax file which can be found
8 "                 at vim.org; below are the syntax files for markdown and reST,
9 "                 respectively:
10 "                       http://www.vim.org/scripts/script.php?script_id=1242
11 "                       http://www.vim.org/scripts/script.php?script_id=973
12 "               - put the file into your syntax directory (e.g. ~/.vim/syntax)
13 "               - if you use markdown (with .mdwn extension) add sth like below
14 "                 in your VIM startup file:
15 "                       au BufNewFile,BufRead *.mdwn set ft=ikiwiki
16 "               - if you use a different markup other than markdown (e.g. reST)
17 "                 make sure to setup 'g:ikiwiki_render_filetype' properly in
18 "                 your startup file (skip this step for mkd.vim, it should work
19 "                 out of the box)
20 " Todo:
21 "               - revamp the whole file so as to detect valid ikiwiki directives
22 "                 and parameters (needs a serious work)
24 let s:cpo_save = &cpo
25 set cpo&vim
27 " Load the base syntax (default to markdown) if nothing was loaded.
28 if !exists("b:current_syntax")
29         let s:ikiwiki_render_filetype = "mkd"
30         if exists("g:ikiwiki_render_filetype")
31                 let s:ikiwiki_render_filetype = g:ikiwiki_render_filetype
32         endif
33         exe 'runtime! syntax/' . s:ikiwiki_render_filetype . '.vim'
34 endif
36 unlet b:current_syntax
38 syn case match
40 syn region ikiwikiLinkContent matchgroup=ikiwikiLink start=+\[\[\(\w\+\s\+\)\{,1}+ end=+\]\]+ contains=ikiwikiLinkNested,ikiwikiParam,ikiwikiNoParam
41 syn region ikiwikiLinkNested matchgroup=ikiwikiLinkNested start=+"""+ end=+"""+ contains=ikiwikiLinkContent contained
43 " FIXME: Below is an ugly hack to prevent highlighting of simple links
44 "        as directives.  Links with spaces are still problematic though.
45 syn region ikiwikiNoParam start=+\[\[[^|=]\+|+ end=+[^|=]\+\]\]+ keepend contains=ikiwikiMagic,ikiwikiDelim
47 syn match ikiwikiDelim "\(\[\[\|\]\]\)" contained
48 syn match  ikiwikiMagic "|" contained 
49 syn match  ikiwikiParam "\<\i\+\ze=" nextgroup=ikiwikiParamAssign contained
50 syn match  ikiwikiParamAssign "=" nextgroup=ikiwikiValue contained
51 syn region ikiwikiValue start=+"[^"]+hs=e-1 end=+[^"]"+ skip=+\\"+ keepend contains=ikiwikiValueMagic,ikiwikiDelim contained 
52 syn match  ikiwikiValueMagic +\(!\<\|\*\|\<\(and\|or\)\>\|\<\i*(\|\>)\)+ contained 
54 syn sync minlines=50
56 hi def link ikiwikiLink Statement
57 hi def link ikiwikiLinkNested String
58 hi def link ikiwikiLinkContent Underlined
60 hi def link ikiwikiMagic Operator
61 hi def link ikiwikiDelim Operator
62 hi def link ikiwikiNoParam Underlined
63 hi def link ikiwikiParam Identifier
64 hi def link ikiwikiParamAssign Operator
65 hi def link ikiwikiValue String
66 hi def link ikiwikiValueMagic Type
68 let b:current_syntax = "ikiwiki"
69 unlet s:cpo_save
71 " vim:ts=8:sts=8:noet