nroff.vim 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. " VIM syntax file
  2. " Language: nroff/groff
  3. " Maintainer: Pedro Alejandro López-Valencia <palopezv@gmail.com>
  4. " URL: http://vorbote.wordpress.com/
  5. " Last Change: 2012 Feb 2
  6. "
  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. " quit when a syntax file was already loaded
  26. "
  27. if exists("b:current_syntax")
  28. finish
  29. endif
  30. let s:cpo_save = &cpo
  31. set cpo&vim
  32. "
  33. " {{{1 plugin settings...
  34. "
  35. " {{{2 enable spacing error highlighting
  36. "
  37. if exists("nroff_space_errors")
  38. syn match nroffError /\s\+$/
  39. syn match nroffSpaceError /[.,:;!?]\s\{2,}/
  40. endif
  41. "
  42. "
  43. " {{{1 Special file settings
  44. "
  45. " {{{2 ms exdented paragraphs are not in the default paragraphs list.
  46. "
  47. setlocal paragraphs+=XP
  48. "
  49. " {{{2 Activate navigation to preporcessor sections.
  50. "
  51. if exists("b:preprocs_as_sections")
  52. setlocal sections=EQTSPS[\ G1GS
  53. endif
  54. " {{{1 Escape sequences
  55. " ------------------------------------------------------------
  56. syn match nroffEscChar /\\[CN]/ nextgroup=nroffEscCharArg
  57. syn match nroffEscape /\\[*fgmnYV]/ nextgroup=nroffEscRegPar,nroffEscRegArg
  58. syn match nroffEscape /\\s[+-]\=/ nextgroup=nroffSize
  59. syn match nroffEscape /\\[$AbDhlLRvxXZ]/ nextgroup=nroffEscPar,nroffEscArg
  60. syn match nroffEscRegArg /./ contained
  61. syn match nroffEscRegArg2 /../ contained
  62. syn match nroffEscRegPar /(/ contained nextgroup=nroffEscRegArg2
  63. syn match nroffEscArg /./ contained
  64. syn match nroffEscArg2 /../ contained
  65. syn match nroffEscPar /(/ contained nextgroup=nroffEscArg2
  66. syn match nroffSize /\((\d\)\=\d/ contained
  67. syn region nroffEscCharArg start=/'/ end=/'/ contained
  68. syn region nroffEscArg start=/'/ end=/'/ contained contains=nroffEscape,@nroffSpecial
  69. if exists("b:nroff_is_groff")
  70. syn region nroffEscRegArg matchgroup=nroffEscape start=/\[/ end=/\]/ contained oneline
  71. syn region nroffSize matchgroup=nroffEscape start=/\[/ end=/\]/ contained
  72. endif
  73. syn match nroffEscape /\\[adprtu{}]/
  74. syn match nroffEscape /\\$/
  75. syn match nroffEscape /\\\$[@*]/
  76. " {{{1 Strings and special characters
  77. " ------------------------------------------------------------
  78. syn match nroffSpecialChar /\\[\\eE?!-]/
  79. syn match nroffSpace "\\[&%~|^0)/,]"
  80. syn match nroffSpecialChar /\\(../
  81. if exists("b:nroff_is_groff")
  82. syn match nroffSpecialChar /\\\[[^]]*]/
  83. syn region nroffPreserve matchgroup=nroffSpecialChar start=/\\?/ end=/\\?/ oneline
  84. endif
  85. syn region nroffPreserve matchgroup=nroffSpecialChar start=/\\!/ end=/$/ oneline
  86. syn cluster nroffSpecial contains=nroffSpecialChar,nroffSpace
  87. syn region nroffString start=/"/ end=/"/ skip=/\\$/ contains=nroffEscape,@nroffSpecial contained
  88. syn region nroffString start=/'/ end=/'/ skip=/\\$/ contains=nroffEscape,@nroffSpecial contained
  89. " {{{1 Numbers and units
  90. " ------------------------------------------------------------
  91. syn match nroffNumBlock /[0-9.]\a\=/ contained contains=nroffNumber
  92. syn match nroffNumber /\d\+\(\.\d*\)\=/ contained nextgroup=nroffUnit,nroffBadChar
  93. syn match nroffNumber /\.\d\+)/ contained nextgroup=nroffUnit,nroffBadChar
  94. syn match nroffBadChar /./ contained
  95. syn match nroffUnit /[icpPszmnvMu]/ contained
  96. " {{{1 Requests
  97. " ------------------------------------------------------------
  98. " Requests begin with . or ' at the beginning of a line, or
  99. " after .if or .ie.
  100. syn match nroffReqLeader /^[.']/ nextgroup=nroffReqName skipwhite
  101. syn match nroffReqLeader /[.']/ contained nextgroup=nroffReqName skipwhite
  102. if exists("b:nroff_is_groff")
  103. "
  104. " GNU troff allows long request names
  105. "
  106. syn match nroffReqName /[^\t \\\[?]\+/ contained nextgroup=nroffReqArg
  107. else
  108. syn match nroffReqName /[^\t \\\[?]\{1,2}/ contained nextgroup=nroffReqArg
  109. endif
  110. syn region nroffReqArg start=/\S/ skip=/\\$/ end=/$/ contained contains=nroffEscape,@nroffSpecial,nroffString,nroffError,nroffSpaceError,nroffNumBlock,nroffComment
  111. " {{{2 Conditional: .if .ie .el
  112. syn match nroffReqName /\(if\|ie\)/ contained nextgroup=nroffCond skipwhite
  113. syn match nroffReqName /el/ contained nextgroup=nroffReqLeader skipwhite
  114. syn match nroffCond /\S\+/ contained nextgroup=nroffReqLeader skipwhite
  115. " {{{2 String definition: .ds .as
  116. syn match nroffReqname /[da]s/ contained nextgroup=nroffDefIdent skipwhite
  117. syn match nroffDefIdent /\S\+/ contained nextgroup=nroffDefinition skipwhite
  118. syn region nroffDefinition matchgroup=nroffSpecialChar start=/"/ matchgroup=NONE end=/\\"/me=e-2 skip=/\\$/ start=/\S/ end=/$/ contained contains=nroffDefSpecial
  119. syn match nroffDefSpecial /\\$/ contained
  120. syn match nroffDefSpecial /\\\((.\)\=./ contained
  121. if exists("b:nroff_is_groff")
  122. syn match nroffDefSpecial /\\\[[^]]*]/ contained
  123. endif
  124. " {{{2 Macro definition: .de .am, also diversion: .di
  125. syn match nroffReqName /\(d[ei]\|am\)/ contained nextgroup=nroffIdent skipwhite
  126. syn match nroffIdent /[^[?( \t]\+/ contained
  127. if exists("b:nroff_is_groff")
  128. syn match nroffReqName /als/ contained nextgroup=nroffIdent skipwhite
  129. endif
  130. " {{{2 Register definition: .rn .rr
  131. syn match nroffReqName /[rn]r/ contained nextgroup=nroffIdent skipwhite
  132. if exists("b:nroff_is_groff")
  133. syn match nroffReqName /\(rnn\|aln\)/ contained nextgroup=nroffIdent skipwhite
  134. endif
  135. " {{{1 eqn/tbl/pic
  136. " ------------------------------------------------------------
  137. " <jp>
  138. " XXX: write proper syntax highlight for eqn / tbl / pic ?
  139. " <jp />
  140. syn region nroffEquation start=/^\.\s*EQ\>/ end=/^\.\s*EN\>/
  141. syn region nroffTable start=/^\.\s*TS\>/ end=/^\.\s*TE\>/
  142. syn region nroffPicture start=/^\.\s*PS\>/ end=/^\.\s*PE\>/
  143. syn region nroffRefer start=/^\.\s*\[\>/ end=/^\.\s*\]\>/
  144. syn region nroffGrap start=/^\.\s*G1\>/ end=/^\.\s*G2\>/
  145. syn region nroffGremlin start=/^\.\s*GS\>/ end=/^\.\s*GE|GF\>/
  146. " {{{1 Comments
  147. " ------------------------------------------------------------
  148. syn region nroffIgnore start=/^[.']\s*ig/ end=/^['.]\s*\./
  149. syn match nroffComment /\(^[.']\s*\)\=\\".*/ contains=nroffTodo
  150. syn match nroffComment /^'''.*/ contains=nroffTodo
  151. if exists("b:nroff_is_groff")
  152. syn match nroffComment "\\#.*$" contains=nroffTodo
  153. endif
  154. syn keyword nroffTodo TODO XXX FIXME contained
  155. " {{{1 Hilighting
  156. " ------------------------------------------------------------
  157. "
  158. "
  159. " Define the default highlighting.
  160. " Only when an item doesn't have highlighting yet
  161. "
  162. hi def link nroffEscChar nroffSpecialChar
  163. hi def link nroffEscCharAr nroffSpecialChar
  164. hi def link nroffSpecialChar SpecialChar
  165. hi def link nroffSpace Delimiter
  166. hi def link nroffEscRegArg2 nroffEscRegArg
  167. hi def link nroffEscRegArg nroffIdent
  168. hi def link nroffEscArg2 nroffEscArg
  169. hi def link nroffEscPar nroffEscape
  170. hi def link nroffEscRegPar nroffEscape
  171. hi def link nroffEscArg nroffEscape
  172. hi def link nroffSize nroffEscape
  173. hi def link nroffEscape Preproc
  174. hi def link nroffIgnore Comment
  175. hi def link nroffComment Comment
  176. hi def link nroffTodo Todo
  177. hi def link nroffReqLeader nroffRequest
  178. hi def link nroffReqName nroffRequest
  179. hi def link nroffRequest Statement
  180. hi def link nroffCond PreCondit
  181. hi def link nroffDefIdent nroffIdent
  182. hi def link nroffIdent Identifier
  183. hi def link nroffEquation PreProc
  184. hi def link nroffTable PreProc
  185. hi def link nroffPicture PreProc
  186. hi def link nroffRefer PreProc
  187. hi def link nroffGrap PreProc
  188. hi def link nroffGremlin PreProc
  189. hi def link nroffNumber Number
  190. hi def link nroffBadChar nroffError
  191. hi def link nroffSpaceError nroffError
  192. hi def link nroffError Error
  193. hi def link nroffPreserve String
  194. hi def link nroffString String
  195. hi def link nroffDefinition String
  196. hi def link nroffDefSpecial Special
  197. let b:current_syntax = "nroff"
  198. let &cpo = s:cpo_save
  199. unlet s:cpo_save
  200. " vim600: set fdm=marker fdl=2: