Add an error check for correct formatting in Deflate uncompressed
[sgt/halibut] / misc / halibut.vim
CommitLineData
4d8caeda 1" Vim syntax file
2" Language: Halibut
3" Maintainer: Jacob Nevins <jacobn+vim@chiark.greenend.org.uk>
c5785c53 4" URL: http://www.chiark.greenend.org.uk/~sgtatham/halibut/
4d8caeda 5" Filenames: *.but
104b744c 6" Version: $Id: halibut.vim,v 1.12 2004/07/16 12:54:59 jacob Exp $
4d8caeda 7
c5785c53 8" I've never been entirely comfortable with vim's syntax highlighting
9" facilities, so this may have all sorts of nasty loose ends, corner cases
10" etc, but it works for me.
4d8caeda 11" I have no idea if it's compatible with vim <6.1.
12
13" Based on docs in Halibut CVS 2004-03-31
14
9d62829c 15" FIXME:
16" - sync - last blank line, \quote, \lcont
17" - add "display" etc for speed?
18
4d8caeda 19" Rune from vim 6.1 help
20" For version 5.x: Clear all syntax items
21" For version 6.x: Quit when a syntax file was already loaded
22if version < 600
23 syn clear
24elseif exists("b:current_syntax")
25 finish
26endif
27
28" Halibut is case-sensitive.
29syn case match
30
31" Fallbacks -- if these characters are seen in text and not caught by
32" anything below, it's probably a syntax violation.
33syn match butIllegalChar "{"
34syn match butIllegalChar "}"
35syn match butIllegalChar "\\"
36
37" Simple-minded fallback to highlight any command we don't recognise,
38" and assume it has textual arguments.
08f82d84 39" (matches current iscmd() in input.c; there are some oddballs which
40" don't fit this handled specially below)
41syn match butCmdGeneric "\\[A-Za-z0-9]\+" nextgroup=butTextArg
4d8caeda 42
43syn cluster butText contains=butLiteral,@butCmd,butTodo
44
08f82d84 45" The special one-character "commands".
46" XXX might want to split up? Can all these appear in \k{...}?
4d8caeda 47syn match butLiteral "\\[-{}_.\\]"
48
49" This isn't specific to Halibut, but is often useful.
50syn keyword butTodo XXX FIXME TODO
51
52" Specific processing comes after the generic stuff above.
53
54" Paragraph level stuff.
55
56" Literals -- might need to come before \e{}, \c{}
57syn region butQuoteLit matchgroup=butCmdSpecific start="\\c\_s\@=" matchgroup=NONE end="$"
58syn region butQLEmph matchgroup=butCmdSpecific start="\\e\_s\@=" matchgroup=NONE end="$" contains=butQLEmphInv
59" Highlight invalid characters in emphasis line, cos I'll never remember.
60syn match butQLEmphInv "\S\@=[^bi]" contained
61
62" Paragraph level comment -- might need to come before inline comment.
c44dc6a4 63syn region butCommentPara start="\\#" end="^\s*$" contains=butTodo
4d8caeda 64
65" Inline comments -- nested braces are honoured.
eb4d33e6 66syn region butComment matchgroup=Comment start="\\#{" skip="\\}" end="}" contains=butCommentBrace,butTodo
67syn region butCommentBrace start="{" skip="\\}" end="}" contains=butCommentBrace,butTodo contained transparent
4d8caeda 68
69" Section headings - a bit hairy. Order wrt rest of file is important.
c5785c53 70syn match butCmdSpecific "\\\(S\d\|[CAHS]\)" nextgroup=butIdentArgH
4d8caeda 71" butIdentArgH -> butTextArgH? -> this, which highlights the rest of the para:
72syn region butTextHeading start="" end="^\s*$" contained contains=@butText
c5785c53 73" Unadorned headings
74syn match butCmdSpecific "\\U\_s\@=" nextgroup=butTextHeading
4d8caeda 75" ...and overall title
c5785c53 76syn match butCmdSpecific "\\title\_s\@=" nextgroup=butTextHeading
4d8caeda 77
9d62829c 78" Bulleted lists -- arguments optional
79syn match butCmdSpecific "\\\(b\|n\|dd\)[^A-Za-z0-9]\@=" nextgroup=butIdentArg
4d8caeda 80
81" Config
82syn match butCmdSpecific "\\cfg{\@=" nextgroup=butCfgArg
83
84" Index/biblio stuff
85syn match butCmdSpecific "\\IM{\@=" nextgroup=butIMArg
86syn match butCmdSpecific "\\BR\={\@=" nextgroup=butIdentArg
87syn match butCmdSpecific "\\nocite{\@=" nextgroup=butIdentArg
88
89" Macros
90syn match butCmdSpecific "\\define{\@=" nextgroup=butIdentArg
91
92" Specific inline commands
93" (Some of these are defined out of paranoia about clashes with code quotes.)
104b744c 94" Indexing -- invisible entries. (includes \I\c, \I\cw; \I\e left; no \q, \cq)
a697063f 95syn match butCmdSpecific "\\I\(\\cw\|\\c\)\={\@=" nextgroup=butIndexArg
4d8caeda 96" Formatting.
97syn match butCmdSpecific "\\e{\@=" nextgroup=butEmphArg
98syn match butCmdSpecific "\\c{\@=" nextgroup=butTextArg
99syn match butCmdSpecific "\\cw{\@=" nextgroup=butTextArg
104b744c 100syn match butCmdSpecific "\\cq{\@=" nextgroup=butTextArg
4d8caeda 101syn match butCmdSpecific "\\W{\@=" nextgroup=butHyperArg
4d8caeda 102" Xref commands
103syn match butCmdSpecific "\\[kK]{\@=" nextgroup=butIdentArg
104" Unicode literal -- a bit special.
ac415fbe 105syn match butLiteral "\\u\x\{,4}" nextgroup=butTextArg
4d8caeda 106
107" Command cluster.
be78a7b9 108syn cluster butCmd contains=butCmdGeneric,butCmdSpecific,butComment,butQuoteLit,butQLEmph,butCommentPara,butLiteral
4d8caeda 109
110" Types of argument. XXX is this cluster still useful?
111syn cluster butArgument contains=butTextArg,butIdentArg,butEmphArgmbutCfgArg,butIdentArgH,butTextArgH
112" Generic identifier.
113syn region butIdentArg matchgroup=butDelimiter start="{" skip="\\}" end="}" nextgroup=@butArgument contained contains=butLiteral
114" Specific chain for headings (needs to come after other heading material)
115syn region butTextArgH matchgroup=butDelimiter start="{" skip="\\}" end="}" nextgroup=butTextHeading contained contains=@butText
116syn region butIdentArgH matchgroup=butDelimiter start="{" skip="\\}" end="}" nextgroup=butTextArgH,butTextHeading contained contains=butLiteral
117" Specific hack for \cfg{}
118syn region butCfgArg matchgroup=butDelimiter start="{" skip="\\}" end="}" nextgroup=butCfgArg contained contains=butLiteral
119" Generic argument to be emphasised
120syn region butEmphArg matchgroup=butDelimiter start="{" skip="\\}" end="}" contained contains=@butText
121" Specific hack for \W{}{}
122syn region butHyperArg matchgroup=butDelimiter start="{" skip="\\}" end="}" contained nextgroup=butTextArg
123" Specific hack for \I{}
124syn region butIndexArg matchgroup=butDelimiter start="{" skip="\\}" end="}" contained contains=@butText
125" Specific hack for \IM{}{}...
3df7c0ec 126syn region butIMArg matchgroup=butDelimiter start="{" skip="\\}" end="}" contained nextgroup=butIMArg contains=@butText
4d8caeda 127" Default argument (due to being last).
c5785c53 128syn region butTextArg matchgroup=butDelimiter start="{" skip="\\}" end="}" nextgroup=@butArgument contained contains=@butText transparent
4d8caeda 129
130" Rune from vim 6.1 help
131if version >= 508 || !exists("did_halibut_syn_inits")
132 if version < 508
133 let did_halibut_syn_inits = 1
134 command -nargs=+ HiLink hi link <args>
135 else
136 command -nargs=+ HiLink hi def link <args>
137 endif
138
139 HiLink butCmdGeneric Statement
140 HiLink butCmdSpecific Statement
141
142 HiLink butLiteral SpecialChar
143
144 HiLink butQLEmphInv Error
145 HiLink butIllegalChar Error
146
147 HiLink butComment Comment
148 HiLink butCommentPara Comment
149
150 HiLink butDelimiter Delimiter
151
152 HiLink butIdentArg Identifier
153 HiLink butIdentArgH Identifier
154 HiLink butCfgArg Identifier
155 HiLink butEmphArg Underlined
156 HiLink butHyperArg Underlined
157 HiLink butIndexArg Identifier
158 HiLink butIMArg Identifier
159
160 HiLink butTextHeading Underlined
161
162 HiLink butTodo Todo
163
164 delcommand HiLink
165endif
166
167" b: local to current buffer
168let b:current_syntax = "halibut"