Merge branch 'vim-with-runtime' into feat/quickfix-title
[vim_extended.git] / runtime / syntax / nroff.vim
blob6f2a13134c50f5674736929882404544e2f7a790
1 " VIM syntax file
2 " Language:     nroff/groff
3 " Maintainer:   Alejandro López-Valencia <dradul@yahoo.com>
4 " URL:          http://dradul.tripod.com/vim
5 " Last Change:  2006 Apr 14
7 " {{{1 Acknowledgements
9 " ACKNOWLEDGEMENTS:
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.
15 " {{{1 Todo
17 " TODO:
19 " * Write syntax highlighting files for the preprocessors,
20 "       and integrate with nroff.vim.
23 " {{{1 Start syntax highlighting.
25 " For version 5.x: Clear all syntax items
26 " For version 6.x: Quit when a syntax file was already loaded
28 if version < 600
29         syntax clear
30 elseif exists("b:current_syntax")
31         finish
32 endif
35 " {{{1 plugin settings...
37 " {{{2 enable spacing error highlighting
39 if exists("nroff_space_errors")
40         syn match nroffError /\s\+$/
41         syn match nroffSpaceError /[.,:;!?]\s\{2,}/
42 endif
45 " {{{1 Special file settings
47 " {{{2  ms exdented paragraphs are not in the default paragraphs list.
49 setlocal paragraphs+=XP
51 " {{{2 Activate navigation to preporcessor sections.
53 if exists("b:preprocs_as_sections")
54         setlocal sections=EQTSPS[\ G1GS
55 endif
57 " {{{1 Escape sequences
58 " ------------------------------------------------------------
60 syn match nroffEscChar /\\[CN]/ nextgroup=nroffEscCharArg
61 syn match nroffEscape /\\[*fgmnYV]/ nextgroup=nroffEscRegPar,nroffEscRegArg
62 syn match nroffEscape /\\s[+-]\=/ nextgroup=nroffSize
63 syn match nroffEscape /\\[$AbDhlLRvxXZ]/ nextgroup=nroffEscPar,nroffEscArg
65 syn match nroffEscRegArg /./ contained
66 syn match nroffEscRegArg2 /../ contained
67 syn match nroffEscRegPar /(/ contained nextgroup=nroffEscRegArg2
68 syn match nroffEscArg /./ contained
69 syn match nroffEscArg2 /../ contained
70 syn match nroffEscPar /(/ contained nextgroup=nroffEscArg2
71 syn match nroffSize /\((\d\)\=\d/ contained
73 syn region nroffEscCharArg start=/'/ end=/'/ contained
74 syn region nroffEscArg start=/'/ end=/'/ contained contains=nroffEscape,@nroffSpecial
76 if exists("b:nroff_is_groff")
77         syn region nroffEscRegArg matchgroup=nroffEscape start=/\[/ end=/\]/ contained oneline
78         syn region nroffSize matchgroup=nroffEscape start=/\[/ end=/\]/ contained
79 endif
81 syn match nroffEscape /\\[adprtu{}]/
82 syn match nroffEscape /\\$/
83 syn match nroffEscape /\\\$[@*]/
85 " {{{1 Strings and special characters
86 " ------------------------------------------------------------
88 syn match nroffSpecialChar /\\[\\eE?!-]/
89 syn match nroffSpace "\\[&%~|^0)/,]"
90 syn match nroffSpecialChar /\\(../
92 if exists("b:nroff_is_groff")
93         syn match nroffSpecialChar /\\\[[^]]*]/
94         syn region nroffPreserve  matchgroup=nroffSpecialChar start=/\\?/ end=/\\?/ oneline
95 endif
97 syn region nroffPreserve matchgroup=nroffSpecialChar start=/\\!/ end=/$/ oneline
99 syn cluster nroffSpecial contains=nroffSpecialChar,nroffSpace
102 syn region nroffString start=/"/ end=/"/ skip=/\\$/ contains=nroffEscape,@nroffSpecial contained
103 syn region nroffString start=/'/ end=/'/ skip=/\\$/ contains=nroffEscape,@nroffSpecial contained
106 " {{{1 Numbers and units
107 " ------------------------------------------------------------
108 syn match nroffNumBlock /[0-9.]\a\=/ contained contains=nroffNumber
109 syn match nroffNumber /\d\+\(\.\d*\)\=/ contained nextgroup=nroffUnit,nroffBadChar
110 syn match nroffNumber /\.\d\+)/ contained nextgroup=nroffUnit,nroffBadChar
111 syn match nroffBadChar /./ contained
112 syn match nroffUnit /[icpPszmnvMu]/ contained
115 " {{{1 Requests
116 " ------------------------------------------------------------
118 " Requests begin with . or ' at the beginning of a line, or
119 " after .if or .ie.
121 syn match nroffReqLeader /^[.']/        nextgroup=nroffReqName skipwhite
122 syn match nroffReqLeader /[.']/ contained nextgroup=nroffReqName skipwhite
124 if exists("b:nroff_is_groff")
126 " GNU troff allows long request names
128         syn match nroffReqName /[^\t \\\[?]\+/ contained nextgroup=nroffReqArg
129 else
130         syn match nroffReqName /[^\t \\\[?]\{1,2}/ contained nextgroup=nroffReqArg
131 endif
133 syn region nroffReqArg start=/\S/ skip=/\\$/ end=/$/ contained contains=nroffEscape,@nroffSpecial,nroffString,nroffError,nroffSpaceError,nroffNumBlock,nroffComment
135 " {{{2 Conditional: .if .ie .el
136 syn match nroffReqName /\(if\|ie\)/ contained nextgroup=nroffCond skipwhite
137 syn match nroffReqName /el/ contained nextgroup=nroffReqLeader skipwhite
138 syn match nroffCond /\S\+/ contained nextgroup=nroffReqLeader skipwhite
140 " {{{2 String definition: .ds .as
141 syn match nroffReqname /[da]s/ contained nextgroup=nroffDefIdent skipwhite
142 syn match nroffDefIdent /\S\+/ contained nextgroup=nroffDefinition skipwhite
143 syn region nroffDefinition matchgroup=nroffSpecialChar start=/"/ matchgroup=NONE end=/\\"/me=e-2 skip=/\\$/ start=/\S/ end=/$/ contained contains=nroffDefSpecial
144 syn match nroffDefSpecial /\\$/ contained
145 syn match nroffDefSpecial /\\\((.\)\=./ contained
147 if exists("b:nroff_is_groff")
148         syn match nroffDefSpecial /\\\[[^]]*]/ contained
149 endif
151 " {{{2 Macro definition: .de .am, also diversion: .di
152 syn match nroffReqName /\(d[ei]\|am\)/ contained nextgroup=nroffIdent skipwhite
153 syn match nroffIdent /[^[?( \t]\+/ contained
154 if exists("b:nroff_is_groff")
155         syn match nroffReqName /als/ contained nextgroup=nroffIdent skipwhite
156 endif
158 " {{{2 Register definition: .rn .rr
159 syn match nroffReqName /[rn]r/ contained nextgroup=nroffIdent skipwhite
160 if exists("b:nroff_is_groff")
161         syn match nroffReqName /\(rnn\|aln\)/ contained nextgroup=nroffIdent skipwhite
162 endif
165 " {{{1 eqn/tbl/pic
166 " ------------------------------------------------------------
167 " <jp>
168 " XXX: write proper syntax highlight for eqn / tbl / pic ?
169 " <jp />
171 syn region nroffEquation start=/^\.\s*EQ\>/ end=/^\.\s*EN\>/
172 syn region nroffTable start=/^\.\s*TS\>/ end=/^\.\s*TE\>/
173 syn region nroffPicture start=/^\.\s*PS\>/ end=/^\.\s*PE\>/
174 syn region nroffRefer start=/^\.\s*\[\>/ end=/^\.\s*\]\>/
175 syn region nroffGrap start=/^\.\s*G1\>/ end=/^\.\s*G2\>/
176 syn region nroffGremlin start=/^\.\s*GS\>/ end=/^\.\s*GE|GF\>/
178 " {{{1 Comments
179 " ------------------------------------------------------------
181 syn region nroffIgnore start=/^[.']\s*ig/ end=/^['.]\s*\./
182 syn match nroffComment /\(^[.']\s*\)\=\\".*/ contains=nroffTodo
183 syn match nroffComment /^'''.*/  contains=nroffTodo
185 if exists("b:nroff_is_groff")
186         syn match nroffComment "\\#.*$" contains=nroffTodo
187 endif
189 syn keyword nroffTodo TODO XXX FIXME contained
191 " {{{1 Hilighting
192 " ------------------------------------------------------------
196 " Define the default highlighting.
197 " For version 5.7 and earlier: only when not done already
198 " For version 5.8 and later: only when an item doesn't have highlighting yet
200 if version >= 508 || !exists("did_nroff_syn_inits")
202         if version < 508
203                 let did_nroff_syn_inits = 1
204                 command -nargs=+ HiLink hi link <args>
205         else
206                 command -nargs=+ HiLink hi def link <args>
207         endif
209         HiLink nroffEscChar nroffSpecialChar
210         HiLink nroffEscCharAr nroffSpecialChar
211         HiLink nroffSpecialChar SpecialChar
212         HiLink nroffSpace Delimiter
214         HiLink nroffEscRegArg2 nroffEscRegArg
215         HiLink nroffEscRegArg nroffIdent
217         HiLink nroffEscArg2 nroffEscArg
218         HiLink nroffEscPar nroffEscape
220         HiLink nroffEscRegPar nroffEscape
221         HiLink nroffEscArg nroffEscape
222         HiLink nroffSize nroffEscape
223         HiLink nroffEscape Preproc
225         HiLink nroffIgnore Comment
226         HiLink nroffComment Comment
227         HiLink nroffTodo Todo
229         HiLink nroffReqLeader nroffRequest
230         HiLink nroffReqName nroffRequest
231         HiLink nroffRequest Statement
232         HiLink nroffCond PreCondit
233         HiLink nroffDefIdent nroffIdent
234         HiLink nroffIdent Identifier
236         HiLink nroffEquation PreProc
237         HiLink nroffTable PreProc
238         HiLink nroffPicture PreProc
239         HiLink nroffRefer PreProc
240         HiLink nroffGrap PreProc
241         HiLink nroffGremlin PreProc
243         HiLink nroffNumber Number
244         HiLink nroffBadChar nroffError
245         HiLink nroffSpaceError nroffError
246         HiLink nroffError Error
248         HiLink nroffPreserve String
249         HiLink nroffString String
250         HiLink nroffDefinition String
251         HiLink nroffDefSpecial Special
253         delcommand HiLink
255 endif
257 let b:current_syntax = "nroff"
259 " vim600: set fdm=marker fdl=2: