summaryrefslogtreecommitdiffstats
path: root/.vim/syntax/ikiwiki.vim
blob: 9a93a2316d420b1ce12707f88c5d7229c4d240db (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
" Vim syntax file
" Language:     Ikiwiki (links and directives)
" Maintainer:   Javier Rojas <jerojasro@devnull.li>
" Last Change:  July 18, 2010

" Instructions:
"               - make sure to use the relevant syntax file which can be found
"                 at vim.org; below are the syntax files for markdown and reST,
"                 respectively:
"                 	http://www.vim.org/scripts/script.php?script_id=1242
"			http://www.vim.org/scripts/script.php?script_id=973
"               - if you use a different markup other than markdown (e.g. reST)
"                 make sure to setup 'g:ikiwiki_render_filetype' properly in
"                 your startup file (skip this step for mkd.vim, it should work
"                 out of the box)
" Former Maintainer: Recai Oktaş (roktasATdebian.org)

let s:cpo_save = &cpo
set cpo&vim

"{{{1 Load the base syntax (default to markdown) if nothing was loaded.
if !exists("b:current_syntax")
	let s:ikiwiki_render_filetype = "mkd"
	if exists("g:ikiwiki_render_filetype")
		let s:ikiwiki_render_filetype = g:ikiwiki_render_filetype
	endif
	exe 'runtime! syntax/' . s:ikiwiki_render_filetype . '.vim'
endif " }}}1

if exists("b:current_syntax")
	unlet b:current_syntax
endif

syn case match

" {{{1 wikilink definition.
" {{{2 docs:
" it takes into account:
"
" named links
"   [[link|link text]]
"
" multiline links
"   [[link|text
"     that expands over
"     multiple lines]]
"
"  and not-links
"    \[[not a link]]
" {{{2
syn region ikiBla matchgroup=ikiLinkDelim start=+\[\[\ze[^!]+ end=+\]\]+ 
	 \ contains=ikiLinkVName,ikiLinkText,ikiLinkNameSep
syn region ikiNoLink start=+\\\[\[+ end=+\]\]+ 

syn match ikiLinkNameSep !|! contained nextgroup=ikiLinkText
syn match ikiLinkText !\(\w\|[ -/#.]\)\+! contained
syn match ikiLinkVName !\_[^\]|]\+\ze|! contained nextgroup=ikiLinkNameSep
" }}}1

" {{{1 ikiwiki directives

syn cluster ikiDirContents contains=ikiDirName
syn cluster ikiDirVal contains=ikiDirParamValSimple,ikiDirParamValQuoted,ikiDirParamVal3Q
syn region ikiDirDelim start=+\[\[\!+ end=+\]\]+ contains=@ikiDirContents fold

syn match ikiDirName !\w\+! contained nextgroup=ikiDirParamName skipwhite
syn match ikiDirParamName !\(\w\|[/:.-]\)\+! contained nextgroup=ikiDirAssign,ikiDirParamName skipwhite
syn match ikiDirAssign !=! contained nextgroup=@ikiDirVal skipwhite
syn match ikiDirParamValSimple ![^" \]]\+! contained nextgroup=ikiDirParamName skipwhite skipnl
syn region ikiDirParamValQuoted start=!"! skip=!\\"! end=!"! contained nextgroup=ikiDirParamName skipwhite skipnl
syn region ikiDirParamVal3Q start=!"""! end=!"""! contained nextgroup=ikiDirParamName skipwhite

" }}}1 ikiwiki directives

" {{{1 association to standard syntax groups
"{{{2 wikilinks
hi def link ikiLinkDelim Operator

hi def link ikiLinkText Underlined
hi def link ikiLinkNameSep Operator
"hi def link ikiLinkVName Identifier
hi def link ikiLinkVName HtmlLink

"{{{2 directives
hi def link ikiDirDelim PreProc
hi def link ikiDirName Type
hi def link ikiDirParamName Identifier
hi def link ikiDirAssign Operator
hi def link ikiDirParamValSimple Constant
hi def link ikiDirParamValQuoted Constant
hi def link ikiDirParamVal3Q Constant
" }}}1

syn sync minlines=50

let b:current_syntax = "ikiwiki"
unlet s:cpo_save

" vim:ts=8:sts=8:noet:fdm=marker