blob: 2619d02c444b154a22a1b61d1ec9daeead338db6 [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"
Bram Moolenaar89bcfda2016-08-30 23:26:57 +020025" quit when a syntax file was already loaded
Bram Moolenaar071d4272004-06-13 20:20:40 +000026"
Bram Moolenaar89bcfda2016-08-30 23:26:57 +020027if exists("b:current_syntax")
Bram Moolenaar071d4272004-06-13 20:20:40 +000028 finish
29endif
30
Bram Moolenaarb8ff1fb2012-02-04 21:59:01 +010031let s:cpo_save = &cpo
32set cpo&vim
33
Bram Moolenaar071d4272004-06-13 20:20:40 +000034"
35" {{{1 plugin settings...
36"
37" {{{2 enable spacing error highlighting
38"
39if exists("nroff_space_errors")
40 syn match nroffError /\s\+$/
41 syn match nroffSpaceError /[.,:;!?]\s\{2,}/
42endif
43"
44"
45" {{{1 Special file settings
46"
47" {{{2 ms exdented paragraphs are not in the default paragraphs list.
48"
49setlocal paragraphs+=XP
50"
51" {{{2 Activate navigation to preporcessor sections.
52"
53if exists("b:preprocs_as_sections")
54 setlocal sections=EQTSPS[\ G1GS
55endif
56
57" {{{1 Escape sequences
58" ------------------------------------------------------------
59
60syn match nroffEscChar /\\[CN]/ nextgroup=nroffEscCharArg
61syn match nroffEscape /\\[*fgmnYV]/ nextgroup=nroffEscRegPar,nroffEscRegArg
62syn match nroffEscape /\\s[+-]\=/ nextgroup=nroffSize
63syn match nroffEscape /\\[$AbDhlLRvxXZ]/ nextgroup=nroffEscPar,nroffEscArg
64
65syn match nroffEscRegArg /./ contained
66syn match nroffEscRegArg2 /../ contained
67syn match nroffEscRegPar /(/ contained nextgroup=nroffEscRegArg2
68syn match nroffEscArg /./ contained
69syn match nroffEscArg2 /../ contained
70syn match nroffEscPar /(/ contained nextgroup=nroffEscArg2
71syn match nroffSize /\((\d\)\=\d/ contained
72
73syn region nroffEscCharArg start=/'/ end=/'/ contained
74syn region nroffEscArg start=/'/ end=/'/ contained contains=nroffEscape,@nroffSpecial
75
76if exists("b:nroff_is_groff")
77 syn region nroffEscRegArg matchgroup=nroffEscape start=/\[/ end=/\]/ contained oneline
78 syn region nroffSize matchgroup=nroffEscape start=/\[/ end=/\]/ contained
79endif
80
81syn match nroffEscape /\\[adprtu{}]/
82syn match nroffEscape /\\$/
83syn match nroffEscape /\\\$[@*]/
84
85" {{{1 Strings and special characters
86" ------------------------------------------------------------
87
88syn match nroffSpecialChar /\\[\\eE?!-]/
89syn match nroffSpace "\\[&%~|^0)/,]"
90syn match nroffSpecialChar /\\(../
91
92if exists("b:nroff_is_groff")
93 syn match nroffSpecialChar /\\\[[^]]*]/
94 syn region nroffPreserve matchgroup=nroffSpecialChar start=/\\?/ end=/\\?/ oneline
95endif
96
97syn region nroffPreserve matchgroup=nroffSpecialChar start=/\\!/ end=/$/ oneline
98
99syn cluster nroffSpecial contains=nroffSpecialChar,nroffSpace
100
101
102syn region nroffString start=/"/ end=/"/ skip=/\\$/ contains=nroffEscape,@nroffSpecial contained
103syn region nroffString start=/'/ end=/'/ skip=/\\$/ contains=nroffEscape,@nroffSpecial contained
104
105
106" {{{1 Numbers and units
107" ------------------------------------------------------------
108syn match nroffNumBlock /[0-9.]\a\=/ contained contains=nroffNumber
109syn match nroffNumber /\d\+\(\.\d*\)\=/ contained nextgroup=nroffUnit,nroffBadChar
110syn match nroffNumber /\.\d\+)/ contained nextgroup=nroffUnit,nroffBadChar
111syn match nroffBadChar /./ contained
112syn match nroffUnit /[icpPszmnvMu]/ contained
113
114
115" {{{1 Requests
116" ------------------------------------------------------------
117
118" Requests begin with . or ' at the beginning of a line, or
119" after .if or .ie.
120
121syn match nroffReqLeader /^[.']/ nextgroup=nroffReqName skipwhite
122syn match nroffReqLeader /[.']/ contained nextgroup=nroffReqName skipwhite
123
124if exists("b:nroff_is_groff")
125"
126" GNU troff allows long request names
127"
Bram Moolenaar9e54a0e2006-04-14 20:42:25 +0000128 syn match nroffReqName /[^\t \\\[?]\+/ contained nextgroup=nroffReqArg
Bram Moolenaar071d4272004-06-13 20:20:40 +0000129else
130 syn match nroffReqName /[^\t \\\[?]\{1,2}/ contained nextgroup=nroffReqArg
131endif
132
Bram Moolenaar9e54a0e2006-04-14 20:42:25 +0000133syn region nroffReqArg start=/\S/ skip=/\\$/ end=/$/ contained contains=nroffEscape,@nroffSpecial,nroffString,nroffError,nroffSpaceError,nroffNumBlock,nroffComment
Bram Moolenaar071d4272004-06-13 20:20:40 +0000134
135" {{{2 Conditional: .if .ie .el
136syn match nroffReqName /\(if\|ie\)/ contained nextgroup=nroffCond skipwhite
137syn match nroffReqName /el/ contained nextgroup=nroffReqLeader skipwhite
138syn match nroffCond /\S\+/ contained nextgroup=nroffReqLeader skipwhite
139
140" {{{2 String definition: .ds .as
141syn match nroffReqname /[da]s/ contained nextgroup=nroffDefIdent skipwhite
142syn match nroffDefIdent /\S\+/ contained nextgroup=nroffDefinition skipwhite
143syn region nroffDefinition matchgroup=nroffSpecialChar start=/"/ matchgroup=NONE end=/\\"/me=e-2 skip=/\\$/ start=/\S/ end=/$/ contained contains=nroffDefSpecial
144syn match nroffDefSpecial /\\$/ contained
145syn match nroffDefSpecial /\\\((.\)\=./ contained
146
147if exists("b:nroff_is_groff")
148 syn match nroffDefSpecial /\\\[[^]]*]/ contained
149endif
150
151" {{{2 Macro definition: .de .am, also diversion: .di
152syn match nroffReqName /\(d[ei]\|am\)/ contained nextgroup=nroffIdent skipwhite
153syn match nroffIdent /[^[?( \t]\+/ contained
154if exists("b:nroff_is_groff")
155 syn match nroffReqName /als/ contained nextgroup=nroffIdent skipwhite
156endif
157
158" {{{2 Register definition: .rn .rr
159syn match nroffReqName /[rn]r/ contained nextgroup=nroffIdent skipwhite
160if exists("b:nroff_is_groff")
161 syn match nroffReqName /\(rnn\|aln\)/ contained nextgroup=nroffIdent skipwhite
162endif
163
164
165" {{{1 eqn/tbl/pic
166" ------------------------------------------------------------
167" <jp>
168" XXX: write proper syntax highlight for eqn / tbl / pic ?
169" <jp />
170
171syn region nroffEquation start=/^\.\s*EQ\>/ end=/^\.\s*EN\>/
172syn region nroffTable start=/^\.\s*TS\>/ end=/^\.\s*TE\>/
173syn region nroffPicture start=/^\.\s*PS\>/ end=/^\.\s*PE\>/
174syn region nroffRefer start=/^\.\s*\[\>/ end=/^\.\s*\]\>/
175syn region nroffGrap start=/^\.\s*G1\>/ end=/^\.\s*G2\>/
176syn region nroffGremlin start=/^\.\s*GS\>/ end=/^\.\s*GE|GF\>/
177
178" {{{1 Comments
179" ------------------------------------------------------------
180
181syn region nroffIgnore start=/^[.']\s*ig/ end=/^['.]\s*\./
182syn match nroffComment /\(^[.']\s*\)\=\\".*/ contains=nroffTodo
183syn match nroffComment /^'''.*/ contains=nroffTodo
184
185if exists("b:nroff_is_groff")
186 syn match nroffComment "\\#.*$" contains=nroffTodo
187endif
188
189syn keyword nroffTodo TODO XXX FIXME contained
190
191" {{{1 Hilighting
192" ------------------------------------------------------------
193"
194
195"
196" Define the default highlighting.
Bram Moolenaar89bcfda2016-08-30 23:26:57 +0200197" Only when an item doesn't have highlighting yet
Bram Moolenaar071d4272004-06-13 20:20:40 +0000198"
Bram Moolenaar89bcfda2016-08-30 23:26:57 +0200199command -nargs=+ HiLink hi def link <args>
Bram Moolenaar071d4272004-06-13 20:20:40 +0000200
Bram Moolenaar89bcfda2016-08-30 23:26:57 +0200201HiLink nroffEscChar nroffSpecialChar
202HiLink nroffEscCharAr nroffSpecialChar
203HiLink nroffSpecialChar SpecialChar
204HiLink nroffSpace Delimiter
Bram Moolenaar071d4272004-06-13 20:20:40 +0000205
Bram Moolenaar89bcfda2016-08-30 23:26:57 +0200206HiLink nroffEscRegArg2 nroffEscRegArg
207HiLink nroffEscRegArg nroffIdent
Bram Moolenaar071d4272004-06-13 20:20:40 +0000208
Bram Moolenaar89bcfda2016-08-30 23:26:57 +0200209HiLink nroffEscArg2 nroffEscArg
210HiLink nroffEscPar nroffEscape
Bram Moolenaar071d4272004-06-13 20:20:40 +0000211
Bram Moolenaar89bcfda2016-08-30 23:26:57 +0200212HiLink nroffEscRegPar nroffEscape
213HiLink nroffEscArg nroffEscape
214HiLink nroffSize nroffEscape
215HiLink nroffEscape Preproc
Bram Moolenaar071d4272004-06-13 20:20:40 +0000216
Bram Moolenaar89bcfda2016-08-30 23:26:57 +0200217HiLink nroffIgnore Comment
218HiLink nroffComment Comment
219HiLink nroffTodo Todo
Bram Moolenaar071d4272004-06-13 20:20:40 +0000220
Bram Moolenaar89bcfda2016-08-30 23:26:57 +0200221HiLink nroffReqLeader nroffRequest
222HiLink nroffReqName nroffRequest
223HiLink nroffRequest Statement
224HiLink nroffCond PreCondit
225HiLink nroffDefIdent nroffIdent
226HiLink nroffIdent Identifier
Bram Moolenaar071d4272004-06-13 20:20:40 +0000227
Bram Moolenaar89bcfda2016-08-30 23:26:57 +0200228HiLink nroffEquation PreProc
229HiLink nroffTable PreProc
230HiLink nroffPicture PreProc
231HiLink nroffRefer PreProc
232HiLink nroffGrap PreProc
233HiLink nroffGremlin PreProc
Bram Moolenaar071d4272004-06-13 20:20:40 +0000234
Bram Moolenaar89bcfda2016-08-30 23:26:57 +0200235HiLink nroffNumber Number
236HiLink nroffBadChar nroffError
237HiLink nroffSpaceError nroffError
238HiLink nroffError Error
Bram Moolenaar071d4272004-06-13 20:20:40 +0000239
Bram Moolenaar89bcfda2016-08-30 23:26:57 +0200240HiLink nroffPreserve String
241HiLink nroffString String
242HiLink nroffDefinition String
243HiLink nroffDefSpecial Special
Bram Moolenaar071d4272004-06-13 20:20:40 +0000244
Bram Moolenaar89bcfda2016-08-30 23:26:57 +0200245delcommand HiLink
Bram Moolenaar071d4272004-06-13 20:20:40 +0000246
247let b:current_syntax = "nroff"
248
Bram Moolenaarb8ff1fb2012-02-04 21:59:01 +0100249let &cpo = s:cpo_save
250unlet s:cpo_save
Bram Moolenaar071d4272004-06-13 20:20:40 +0000251" vim600: set fdm=marker fdl=2: