-
Notifications
You must be signed in to change notification settings - Fork 0
/
kag3.vim
104 lines (83 loc) · 3.41 KB
/
kag3.vim
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
100
101
102
103
104
" Vim syntax file
" Language: KAG3
" Maintainer: popkirby <popkirby@gmail.com>
" Last Change: 2012 Mar 12
" Remark: Include TJS syntax.
" Changes: Added folding at [iscript], [macro].
"
" TODO:
if !exists("main_syntax")
if version < 600
syntax clear
elseif exists("b:current_syntax")
finish
endif
let main_syntax = 'kag3'
endif
syntax sync fromstart
syntax case match
" KAG3 comments
" starts when ';' appeared
syntax region kag3Comment start=/^;/ end=/$/
" Strings
syntax region kag3String start=/"/ skip=/\\"/ end=/"/ contained
syntax region kag3String start=/'/ skip=/\\'/ end=/'/ contained
" Labels
syntax region kag3LabelName start=/^\*/ end=/$/ keepend contains=kag3LabelDescription
syntax region kag3LabelDescription start=/|/ end=/$/ contained
" Tags
syntax region kag3Tag start=/\[/ end=/\]/ oneline contains=kag3TagName,kag3Attribute,kag3Boolean,kag3AttrValue,kag3String
syntax region kag3TagOneLine start=/@/ end=/$/ keepend contains=kag3TagName,kag3Attribute,kag3Boolean,kag3AttrValue,kag3String
" Tag name
syntax match kag3TagName "\[[^ \t\]]\+"hs=s+1 contained
syntax match kag3TagName "^@\S\+"hs=s+1 contained
" Tag Attribute
syntax match kag3Attribute "\s+\S+"hs=s+1 contained
" Tag Value
syntax match kag3AttrValue /=[^'" \t][^ \t\]]*/hs=s+1 contained
" Boolean
syntax keyword kag3Boolean true false contained
" Include TJS2 syntax.
if globpath(&rtp, 'syntax/tjs2.vim') != ''
syntax include @kag3Tjs2Top syntax/tjs2.vim
syntax region kag3Tjs2Script start="\[iscript\]"rs=s+9 end="\[endscript\]"me=s-1 keepend contains=@kag3Tjs2Top,kag3Tjs2ScriptTag
syntax region kag3Tjs2Script start="^@iscript"rs=s+8 end="^@endscript"me=s-1 keepend contains=@kag3Tjs2Top,kag3Tjs2ScriptTag
syntax region kag3Tjs2ScriptTag start="\[\(iscript\]\)\@=" end="\]" oneline contained contains=kag3Tjs2ScriptTagName
syntax region kag3Tjs2ScriptTag start="@\(iscript\)\@=" end="$" contained contains=kag3Tjs2ScriptTagName
syntax match kag3Tjs2ScriptTagName "iscript" contained
endif
" Folding
let g:use_kag3_syntax_folding = get(g:, 'use_kag3_syntax_folding', 1)
if g:use_kag3_syntax_folding == 1
syntax region kag3Tjs2ScriptFold1 start="\[iscript\]" end="\[endscript\]" transparent fold keepend
syntax region kag3Tjs2ScriptFold2 start="^@iscript" end="^@endscript" transparent fold keepend
syntax region kag3MacroFold1 start="\[macro" end="\[endmacro\]" transparent fold keepend
syntax region kag3MacroFold2 start="^@macro" end="^@endmacro" transparent fold keepend
set foldmethod=syntax
endif
" Define highlighting
if version >= 508 || !exists("did_kag3_syn_inits")
if version < 508
let did_kag3_syn_inits = 1
command -nargs=+ HiLink hi link <args>
else
command -nargs=+ HiLink hi def link <args>
endif
HiLink kag3Comment Comment
HiLink kag3String String
HiLink kag3LabelName Label
HiLink kag3LabelDescription Special
HiLink kag3Tjs2ScriptTag kag3Tag
HiLink kag3Tag Function
HiLink kag3TagOneLine Identifier
HiLink kag3Tjs2ScriptTagName Identifier
HiLink kag3TagName Statement
HiLink kag3Attribute Type
HiLink kag3AttrValue String
HiLink kag3Boolean Boolean
delcommand HiLink
endif
let b:current_syntax = "kag3"
if main_syntax == 'kag3'
unlet main_syntax
endif