blob: 280ba9e7d9fa57d8298173c01cdf88eb1d45dd7b [file] [log] [blame]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001" VIM syntax file
2" Language: nroff/groff
Bram Moolenaarb8ff1fb2012-02-04 21:59:01 +01003" Maintainer: Pedro Alejandro López-Valencia <palopezv@gmail.com>
4" URL: http://vorbote.wordpress.com/
5" Last Change: 2012 Feb 2
Bram Moolenaar071d4272004-06-13 20:20:40 +00006"
7" {{{1 Acknowledgements
8"
9" ACKNOWLEDGEMENTS:
10"
11" My thanks to Jérôme Plût <Jerome.Plut@ens.fr>, who was the
12" creator and maintainer of this syntax file for several years.
13" May I be as good at it as he has been.
14"
15" {{{1 Todo
16"
17" TODO:
18"
19" * Write syntax highlighting files for the preprocessors,
20" and integrate with nroff.vim.
21"
22"
23" {{{1 Start syntax highlighting.
24"
25" For version 5.x: Clear all syntax items
26" For version 6.x: Quit when a syntax file was already loaded
27"
28if version < 600
29 syntax clear
30elseif exists("b:current_syntax")
31 finish
32endif
33
Bram Moolenaarb8ff1fb2012-02-04 21:59:01 +010034let s:cpo_save = &cpo
35set cpo&vim
36
Bram Moolenaar071d4272004-06-13 20:20:40 +000037"
38" {{{1 plugin settings...
39"
40" {{{2 enable spacing error highlighting
41"
42if exists("nroff_space_errors")
43 syn match nroffError /\s\+$/
44 syn match nroffSpaceError /[.,:;!?]\s\{2,}/
45endif
46"
47"
48" {{{1 Special file settings
49"
50" {{{2 ms exdented paragraphs are not in the default paragraphs list.
51"
52setlocal paragraphs+=XP
53"
54" {{{2 Activate navigation to preporcessor sections.
55"
56if exists("b:preprocs_as_sections")
57 setlocal sections=EQTSPS[\ G1GS
58endif
59
60" {{{1 Escape sequences
61" ------------------------------------------------------------
62
63syn match nroffEscChar /\\[CN]/ nextgroup=nroffEscCharArg
64syn match nroffEscape /\\[*fgmnYV]/ nextgroup=nroffEscRegPar,nroffEscRegArg
65syn match nroffEscape /\\s[+-]\=/ nextgroup=nroffSize
66syn match nroffEscape /\\[$AbDhlLRvxXZ]/ nextgroup=nroffEscPar,nroffEscArg
67
68syn match nroffEscRegArg /./ contained
69syn match nroffEscRegArg2 /../ contained
70syn match nroffEscRegPar /(/ contained nextgroup=nroffEscRegArg2
71syn match nroffEscArg /./ contained
72syn match nroffEscArg2 /../ contained
73syn match nroffEscPar /(/ contained nextgroup=nroffEscArg2
74syn match nroffSize /\((\d\)\=\d/ contained
75
76syn region nroffEscCharArg start=/'/ end=/'/ contained
77syn region nroffEscArg start=/'/ end=/'/ contained contains=nroffEscape,@nroffSpecial
78
79if exists("b:nroff_is_groff")
80 syn region nroffEscRegArg matchgroup=nroffEscape start=/\[/ end=/\]/ contained oneline
81 syn region nroffSize matchgroup=nroffEscape start=/\[/ end=/\]/ contained
82endif
83
84syn match nroffEscape /\\[adprtu{}]/
85syn match nroffEscape /\\$/
86syn match nroffEscape /\\\$[@*]/
87
88" {{{1 Strings and special characters
89" ------------------------------------------------------------
90
91syn match nroffSpecialChar /\\[\\eE?!-]/
92syn match nroffSpace "\\[&%~|^0)/,]"
93syn match nroffSpecialChar /\\(../
94
95if exists("b:nroff_is_groff")
96 syn match nroffSpecialChar /\\\[[^]]*]/
97 syn region nroffPreserve matchgroup=nroffSpecialChar start=/\\?/ end=/\\?/ oneline
98endif
99
100syn region nroffPreserve matchgroup=nroffSpecialChar start=/\\!/ end=/$/ oneline
101
102syn cluster nroffSpecial contains=nroffSpecialChar,nroffSpace
103
104
105syn region nroffString start=/"/ end=/"/ skip=/\\$/ contains=nroffEscape,@nroffSpecial contained
106syn region nroffString start=/'/ end=/'/ skip=/\\$/ contains=nroffEscape,@nroffSpecial contained
107
108
109" {{{1 Numbers and units
110" ------------------------------------------------------------
111syn match nroffNumBlock /[0-9.]\a\=/ contained contains=nroffNumber
112syn match nroffNumber /\d\+\(\.\d*\)\=/ contained nextgroup=nroffUnit,nroffBadChar
113syn match nroffNumber /\.\d\+)/ contained nextgroup=nroffUnit,nroffBadChar
114syn match nroffBadChar /./ contained
115syn match nroffUnit /[icpPszmnvMu]/ contained
116
117
118" {{{1 Requests
119" ------------------------------------------------------------
120
121" Requests begin with . or ' at the beginning of a line, or
122" after .if or .ie.
123
124syn match nroffReqLeader /^[.']/ nextgroup=nroffReqName skipwhite
125syn match nroffReqLeader /[.']/ contained nextgroup=nroffReqName skipwhite
126
127if exists("b:nroff_is_groff")
128"
129" GNU troff allows long request names
130"
Bram Moolenaar9e54a0e2006-04-14 20:42:25 +0000131 syn match nroffReqName /[^\t \\\[?]\+/ contained nextgroup=nroffReqArg
Bram Moolenaar071d4272004-06-13 20:20:40 +0000132else
133 syn match nroffReqName /[^\t \\\[?]\{1,2}/ contained nextgroup=nroffReqArg
134endif
135
Bram Moolenaar9e54a0e2006-04-14 20:42:25 +0000136syn region nroffReqArg start=/\S/ skip=/\\$/ end=/$/ contained contains=nroffEscape,@nroffSpecial,nroffString,nroffError,nroffSpaceError,nroffNumBlock,nroffComment
Bram Moolenaar071d4272004-06-13 20:20:40 +0000137
138" {{{2 Conditional: .if .ie .el
139syn match nroffReqName /\(if\|ie\)/ contained nextgroup=nroffCond skipwhite
140syn match nroffReqName /el/ contained nextgroup=nroffReqLeader skipwhite
141syn match nroffCond /\S\+/ contained nextgroup=nroffReqLeader skipwhite
142
143" {{{2 String definition: .ds .as
144syn match nroffReqname /[da]s/ contained nextgroup=nroffDefIdent skipwhite
145syn match nroffDefIdent /\S\+/ contained nextgroup=nroffDefinition skipwhite
146syn region nroffDefinition matchgroup=nroffSpecialChar start=/"/ matchgroup=NONE end=/\\"/me=e-2 skip=/\\$/ start=/\S/ end=/$/ contained contains=nroffDefSpecial
147syn match nroffDefSpecial /\\$/ contained
148syn match nroffDefSpecial /\\\((.\)\=./ contained
149
150if exists("b:nroff_is_groff")
151 syn match nroffDefSpecial /\\\[[^]]*]/ contained
152endif
153
154" {{{2 Macro definition: .de .am, also diversion: .di
155syn match nroffReqName /\(d[ei]\|am\)/ contained nextgroup=nroffIdent skipwhite
156syn match nroffIdent /[^[?( \t]\+/ contained
157if exists("b:nroff_is_groff")
158 syn match nroffReqName /als/ contained nextgroup=nroffIdent skipwhite
159endif
160
161" {{{2 Register definition: .rn .rr
162syn match nroffReqName /[rn]r/ contained nextgroup=nroffIdent skipwhite
163if exists("b:nroff_is_groff")
164 syn match nroffReqName /\(rnn\|aln\)/ contained nextgroup=nroffIdent skipwhite
165endif
166
167
168" {{{1 eqn/tbl/pic
169" ------------------------------------------------------------
170" <jp>
171" XXX: write proper syntax highlight for eqn / tbl / pic ?
172" <jp />
173
174syn region nroffEquation start=/^\.\s*EQ\>/ end=/^\.\s*EN\>/
175syn region nroffTable start=/^\.\s*TS\>/ end=/^\.\s*TE\>/
176syn region nroffPicture start=/^\.\s*PS\>/ end=/^\.\s*PE\>/
177syn region nroffRefer start=/^\.\s*\[\>/ end=/^\.\s*\]\>/
178syn region nroffGrap start=/^\.\s*G1\>/ end=/^\.\s*G2\>/
179syn region nroffGremlin start=/^\.\s*GS\>/ end=/^\.\s*GE|GF\>/
180
181" {{{1 Comments
182" ------------------------------------------------------------
183
184syn region nroffIgnore start=/^[.']\s*ig/ end=/^['.]\s*\./
185syn match nroffComment /\(^[.']\s*\)\=\\".*/ contains=nroffTodo
186syn match nroffComment /^'''.*/ contains=nroffTodo
187
188if exists("b:nroff_is_groff")
189 syn match nroffComment "\\#.*$" contains=nroffTodo
190endif
191
192syn keyword nroffTodo TODO XXX FIXME contained
193
194" {{{1 Hilighting
195" ------------------------------------------------------------
196"
197
198"
199" Define the default highlighting.
200" For version 5.7 and earlier: only when not done already
201" For version 5.8 and later: only when an item doesn't have highlighting yet
202"
203if version >= 508 || !exists("did_nroff_syn_inits")
204
205 if version < 508
206 let did_nroff_syn_inits = 1
207 command -nargs=+ HiLink hi link <args>
208 else
209 command -nargs=+ HiLink hi def link <args>
210 endif
211
212 HiLink nroffEscChar nroffSpecialChar
213 HiLink nroffEscCharAr nroffSpecialChar
214 HiLink nroffSpecialChar SpecialChar
215 HiLink nroffSpace Delimiter
216
217 HiLink nroffEscRegArg2 nroffEscRegArg
218 HiLink nroffEscRegArg nroffIdent
219
220 HiLink nroffEscArg2 nroffEscArg
221 HiLink nroffEscPar nroffEscape
222
223 HiLink nroffEscRegPar nroffEscape
224 HiLink nroffEscArg nroffEscape
225 HiLink nroffSize nroffEscape
226 HiLink nroffEscape Preproc
227
228 HiLink nroffIgnore Comment
229 HiLink nroffComment Comment
230 HiLink nroffTodo Todo
231
232 HiLink nroffReqLeader nroffRequest
233 HiLink nroffReqName nroffRequest
234 HiLink nroffRequest Statement
235 HiLink nroffCond PreCondit
236 HiLink nroffDefIdent nroffIdent
237 HiLink nroffIdent Identifier
238
239 HiLink nroffEquation PreProc
240 HiLink nroffTable PreProc
241 HiLink nroffPicture PreProc
242 HiLink nroffRefer PreProc
243 HiLink nroffGrap PreProc
244 HiLink nroffGremlin PreProc
245
246 HiLink nroffNumber Number
247 HiLink nroffBadChar nroffError
248 HiLink nroffSpaceError nroffError
249 HiLink nroffError Error
250
251 HiLink nroffPreserve String
252 HiLink nroffString String
253 HiLink nroffDefinition String
254 HiLink nroffDefSpecial Special
255
256 delcommand HiLink
257
258endif
259
260let b:current_syntax = "nroff"
261
Bram Moolenaarb8ff1fb2012-02-04 21:59:01 +0100262let &cpo = s:cpo_save
263unlet s:cpo_save
Bram Moolenaar071d4272004-06-13 20:20:40 +0000264" vim600: set fdm=marker fdl=2: