nroff.vim (7605B)
1 " VIM syntax file 2 " Language: nroff/groff 3 " Maintainer: John Marshall <jmarshall@hey.com> 4 " Previous Maintainer: Pedro Alejandro López-Valencia <palopezv@gmail.com> 5 " Previous Maintainer: Jérôme Plût <Jerome.Plut@ens.fr> 6 " Last Change: 2021 Mar 28 7 " 2025 Apr 24 by Eisuke Kawashima (move options from syntax to ftplugin #17174) 8 " 9 " {{{1 Todo 10 " 11 " TODO: 12 " 13 " * Write syntax highlighting files for the preprocessors, 14 " and integrate with nroff.vim. 15 " 16 " 17 " {{{1 Start syntax highlighting. 18 " 19 " quit when a syntax file was already loaded 20 " 21 if exists("b:current_syntax") 22 finish 23 endif 24 25 let s:cpo_save = &cpo 26 set cpo&vim 27 28 if exists("nroff_is_groff") 29 let b:nroff_is_groff = 1 30 endif 31 32 syn spell toplevel 33 syn case match 34 35 " 36 " {{{1 plugin settings... 37 " 38 " {{{2 enable spacing error highlighting 39 " 40 if exists("nroff_space_errors") 41 syn match nroffError /\s\+$/ 42 syn match nroffSpaceError /[.,:;!?]\s\{2,}/ 43 endif 44 45 " {{{1 Escape sequences 46 " ------------------------------------------------------------ 47 48 syn match nroffEscChar /\\[CN]/ nextgroup=nroffEscCharArg 49 syn match nroffEscape /\\[*fgmnYV]/ nextgroup=nroffEscRegPar,nroffEscRegArg 50 syn match nroffEscape /\\s[+-]\=/ nextgroup=nroffSize 51 syn match nroffEscape /\\[$AbDhlLRvxXZ]/ nextgroup=nroffEscPar,nroffEscArg 52 53 syn match nroffEscRegArg /./ contained 54 syn match nroffEscRegArg2 /../ contained 55 syn match nroffEscRegPar /(/ contained nextgroup=nroffEscRegArg2 56 syn match nroffEscArg /./ contained 57 syn match nroffEscArg2 /../ contained 58 syn match nroffEscPar /(/ contained nextgroup=nroffEscArg2 59 syn match nroffSize /\((\d\)\=\d/ contained 60 61 syn region nroffEscCharArg start=/'/ end=/'/ contained 62 syn region nroffEscArg start=/'/ end=/'/ contained contains=nroffEscape,@nroffSpecial 63 64 if exists("b:nroff_is_groff") 65 syn region nroffEscRegArg matchgroup=nroffEscape start=/\[/ end=/\]/ contained oneline 66 syn region nroffSize matchgroup=nroffEscape start=/\[/ end=/\]/ contained 67 endif 68 69 syn match nroffEscape /\\[adprtu{}]/ 70 syn match nroffEscape /\\$/ 71 syn match nroffEscape /\\\$[@*]/ 72 73 " {{{1 Strings and special characters 74 " ------------------------------------------------------------ 75 76 syn match nroffSpecialChar /\\[\\eE?!-]/ 77 syn match nroffSpace "\\[&%~|^0)/,]" 78 syn match nroffSpecialChar /\\(../ 79 80 if exists("b:nroff_is_groff") 81 syn match nroffSpecialChar /\\\[[^]]*]/ 82 syn region nroffPreserve matchgroup=nroffSpecialChar start=/\\?/ end=/\\?/ oneline 83 endif 84 85 syn region nroffPreserve matchgroup=nroffSpecialChar start=/\\!/ end=/$/ oneline 86 87 syn cluster nroffSpecial contains=nroffSpecialChar,nroffSpace 88 89 90 syn region nroffString start=/"/ end=/"/ skip=/\\$/ contains=nroffEscape,@nroffSpecial contained 91 syn region nroffString start=/'/ end=/'/ skip=/\\$/ contains=nroffEscape,@nroffSpecial contained 92 93 94 " {{{1 Numbers and units 95 " ------------------------------------------------------------ 96 syn match nroffNumBlock /[0-9.]\a\=/ contained contains=nroffNumber 97 syn match nroffNumber /\d\+\(\.\d*\)\=/ contained nextgroup=nroffUnit,nroffBadChar 98 syn match nroffNumber /\.\d\+)/ contained nextgroup=nroffUnit,nroffBadChar 99 syn match nroffBadChar /./ contained 100 syn match nroffUnit /[icpPszmnvMu]/ contained 101 102 103 " {{{1 Requests 104 " ------------------------------------------------------------ 105 106 " Requests begin with . or ' at the beginning of a line, or 107 " after .if or .ie. 108 109 syn match nroffReqLeader /^[.']/ nextgroup=nroffReqName skipwhite 110 syn match nroffReqLeader /[.']/ contained nextgroup=nroffReqName skipwhite 111 112 if exists("b:nroff_is_groff") 113 " 114 " GNU troff allows long request names 115 " 116 syn match nroffReqName /[^\t \\\[?]\+/ contained nextgroup=nroffReqArg 117 else 118 syn match nroffReqName /[^\t \\\[?]\{1,2}/ contained nextgroup=nroffReqArg 119 endif 120 121 syn region nroffReqArg start=/\S/ skip=/\\$/ end=/$/ contained contains=nroffEscape,@nroffSpecial,nroffString,nroffError,nroffSpaceError,nroffNumBlock,nroffComment 122 123 " {{{2 Conditional: .if .ie .el 124 syn match nroffReqName /\(if\|ie\)/ contained nextgroup=nroffCond skipwhite 125 syn match nroffReqName /el/ contained nextgroup=nroffReqLeader skipwhite 126 syn match nroffCond /\S\+/ contained nextgroup=nroffReqLeader skipwhite 127 128 " {{{2 String definition: .ds .as 129 syn match nroffReqname /[da]s/ contained nextgroup=nroffDefIdent skipwhite 130 syn match nroffDefIdent /\S\+/ contained nextgroup=nroffDefinition skipwhite 131 syn region nroffDefinition matchgroup=nroffSpecialChar start=/"/ matchgroup=NONE end=/\\"/me=e-2 skip=/\\$/ start=/\S/ end=/$/ contained contains=nroffDefSpecial 132 syn match nroffDefSpecial /\\$/ contained 133 syn match nroffDefSpecial /\\\((.\)\=./ contained 134 135 if exists("b:nroff_is_groff") 136 syn match nroffDefSpecial /\\\[[^]]*]/ contained 137 endif 138 139 " {{{2 Macro definition: .de .am, also diversion: .di 140 syn match nroffReqName /\(d[ei]\|am\)/ contained nextgroup=nroffIdent skipwhite 141 syn match nroffIdent /[^[?( \t]\+/ contained 142 if exists("b:nroff_is_groff") 143 syn match nroffReqName /als/ contained nextgroup=nroffIdent skipwhite 144 endif 145 146 " {{{2 Register definition: .rn .rr 147 syn match nroffReqName /[rn]r/ contained nextgroup=nroffIdent skipwhite 148 if exists("b:nroff_is_groff") 149 syn match nroffReqName /\(rnn\|aln\)/ contained nextgroup=nroffIdent skipwhite 150 endif 151 152 153 " {{{1 eqn/tbl/pic 154 " ------------------------------------------------------------ 155 " <jp> 156 " XXX: write proper syntax highlight for eqn / tbl / pic ? 157 " <jp /> 158 159 syn region nroffEquation start=/^\.\s*EQ\>/ end=/^\.\s*EN\>/ 160 syn region nroffTable start=/^\.\s*TS\>/ end=/^\.\s*TE\>/ contains=@Spell 161 syn region nroffPicture start=/^\.\s*PS\>/ end=/^\.\s*PE\>/ 162 syn region nroffRefer start=/^\.\s*\[\>/ end=/^\.\s*\]\>/ contains=@Spell 163 syn region nroffGrap start=/^\.\s*G1\>/ end=/^\.\s*G2\>/ 164 syn region nroffGremlin start=/^\.\s*GS\>/ end=/^\.\s*GE|GF\>/ 165 166 " {{{1 Comments 167 " ------------------------------------------------------------ 168 169 syn region nroffIgnore start=/^[.']\s*ig/ end=/^['.]\s*\./ 170 syn match nroffComment /\(^[.']\s*\)\=\\".*/ contains=nroffTodo,@Spell 171 syn match nroffComment /^'''.*/ contains=nroffTodo,@Spell 172 173 if exists("b:nroff_is_groff") 174 syn match nroffComment "\\#.*$" contains=nroffTodo,@Spell 175 endif 176 177 syn keyword nroffTodo TODO XXX FIXME contained 178 179 " {{{1 Hilighting 180 " ------------------------------------------------------------ 181 " 182 183 " 184 " Define the default highlighting. 185 " Only when an item doesn't have highlighting yet 186 " 187 188 hi def link nroffEscChar nroffSpecialChar 189 hi def link nroffEscCharArg nroffSpecialChar 190 hi def link nroffSpecialChar SpecialChar 191 hi def link nroffSpace Delimiter 192 193 hi def link nroffEscRegArg2 nroffEscRegArg 194 hi def link nroffEscRegArg nroffIdent 195 196 hi def link nroffEscArg2 nroffEscArg 197 hi def link nroffEscPar nroffEscape 198 199 hi def link nroffEscRegPar nroffEscape 200 hi def link nroffEscArg nroffEscape 201 hi def link nroffSize nroffEscape 202 hi def link nroffEscape PreProc 203 204 hi def link nroffIgnore Comment 205 hi def link nroffComment Comment 206 hi def link nroffTodo Todo 207 208 hi def link nroffReqLeader nroffRequest 209 hi def link nroffReqName nroffRequest 210 hi def link nroffRequest Statement 211 hi def link nroffCond PreCondit 212 hi def link nroffDefIdent nroffIdent 213 hi def link nroffIdent Identifier 214 215 hi def link nroffEquation PreProc 216 hi def link nroffTable PreProc 217 hi def link nroffPicture PreProc 218 hi def link nroffRefer PreProc 219 hi def link nroffGrap PreProc 220 hi def link nroffGremlin PreProc 221 222 hi def link nroffNumber Number 223 hi def link nroffBadChar nroffError 224 hi def link nroffSpaceError nroffError 225 hi def link nroffError Error 226 227 hi def link nroffPreserve String 228 hi def link nroffString String 229 hi def link nroffDefinition String 230 hi def link nroffDefSpecial Special 231 232 233 let b:current_syntax = "nroff" 234 235 let &cpo = s:cpo_save 236 unlet s:cpo_save 237 " vim600: set fdm=marker fdl=2: