1 " Copyright (C) 2012-2018 Free Software Foundation, Inc.
3 " Copying and distribution of this file, with or without modification,
4 " are permitted in any medium without royalty provided the copyright
5 " notice and this notice are preserved.
9 " Maintainer: Peter Schaffter (peter@schaffter.ca)
10 " Last Change: So 06 Mär 2005 17:28:13 CET
12 " URL: http://www.cvjb.de/comp/vim/mom.vim
13 " Note: Remove or overwrite troff syntax for *.mom-files with filetype/filedetect.
16 " Mom: Macro set for easy typesetting with troff/nroff/groff.
18 " For version 5.x: Clear all syntax items
19 " For version 6.x: Quit when a syntax file was already loaded
22 elseif exists("b:current_syntax")
26 " Mom is case sensitive
29 " Synchronization, I know it is a huge number, but normal texts can be
33 " Characters allowed in keywords
35 setlocal iskeyword=@,#,$,%,48-57,.,@-@,_,\\,{,},192-255
37 set iskeyword=@,#,$,%,48-57,.,@-@,_,\\,{,},192-255
40 " mom/groff macros and requests (the initial dot or single-quote)
42 " Highlighting carries through to EOL; macro names, requests and
43 " arguments are contained
44 syn match startRequest /^\s*\(\.\|'\)\s*.*$/ contains=momMacro,groffCommentLine,groffRequest,momRegister,groffNoLineBreak,momInteger,groffUnit,momString,momSpecialParam,groffDelimiter,groffRegister,groffPreprocessor,groffBraces
47 syn region momMacro start=/^\s*\(\.\|'\)\s*\zs[A-Z0-9_(){}\[\]]\+/ end=/\s\+\|$/
49 " mom registers and strings
50 syn match momRegister /\(\$\|#\)[A-Za-z][_0-9A-Za-z]*/ contains=momRegisterStart
52 syn match momRegisterStart /#\|\$/ contained
55 syn region momCommentRegion matchgroup=startRequest start='\<\.\(COMMENT\)\|\(SILENT\)\>' end='\<\.\(COMMENT\s\+OFF\)\|\(SILENT\s\+OFF\)\>' skip='$'
58 syn match groffRequest /^\s*\(\.\|'\)\s*\zs[a-z0-9]\+/
60 " groff comment region
61 syn region groffCommentLine start='\(\\!\)\|\(\\"\)\|\(\\#\)' end='$' contains=momTodo
62 syn region groffCommentRegion start="^\s*\.\s*ig" matchgroup=startRequest end="^\.\.$" contains=startRequest
64 " Preprocessor requests
65 syn match groffPreprocessor /[^A-Z]\zs\(EQ\s*$\|EN\s*$\|GS\s*$\|GE\s*$\|GF\s*$\|PS\s*$\|PE\s*$\|R1\s*$\|R2\s*$\|TS\s*$\|TE\s*$\|TH\s*$\)/ contained
66 syn match groffPreprocessor /[^A-Z]\zs\(G1\s*$\|G2\s*$\|IS\s*$\|IE\s*$\|cstart\s*$\|cend\s*$\)/ contained
68 " Preprocessor requests for refer
69 syn match groffPreprocessor /\(\[\s*$\|\]\s*$\)/ contained
72 syn region momString matchgroup=startRequest start='"\zs' end='"\|$' contains=groffNoLineBreak,groffGreek,groffSpecialChar,momInteger,momFloatEN,momFloatDE,momBracketRegion,momBracketError,momSpecialMove contained
75 syn match groffSpecialChar '\\\((\|\[\)[-+A-Za-z0-9*<>=~!\/]\+\]*'
78 syn match groffGreek '\\(\*[A-Za-z]\+'
81 syn match groffHyphenation '\\%'
83 " Masking of line breaks
84 syn match groffNoLineBreak /\\\s*$/ contains=groffBraces
86 " groff number and string register delimiters
87 syn region groffDelimiter start=/\\*\\\(n+*\|\*\)\((\|\[\)\</ end=/\(\s\|\]\|$\)/ contains=momRegister,groffRegister,groffOperators
90 syn match groffRegister /\\\((\|\[\)\zs\.*[a-z]\+/
93 syn match groffOperators /\(+\|-\|\/\|\*[^[]\)/ contained
96 syn match groffUnit '[-+]\=\([0-9]\|]\)\+\zs[icPpvusfz]\=' contained
99 syn match groffBraces /\(\\{\|\\}\)/ contained
102 syn match groffError '\\\[ \+[[:print:]]\+ \+[[:print:]]\+\]'
104 " For version 5.7 and earlier: only when not done already
105 " For version 5.8 and later: only when an item doesn't have highlighting yet
106 if version >= 508 || !exists("did_mom_syn_inits")
108 let did_mom_syn_inits = 1
109 command -nargs=+ HiLink hi link <args>
111 command -nargs=+ HiLink hi def link <args>
114 HiLink groffError Error
115 HiLink groffBraces darkmagenta
116 HiLink groffCommentLine darkcyan
117 HiLink groffCommentRegion cyan
118 HiLink groffDelimiter cyan
119 HiLink groffGreek cyan
120 HiLink groffHyphenation cyan
121 HiLink groffNoLineBreak cyan
122 HiLink groffOperators white
123 HiLink groffPreprocessor brown
124 HiLink groffRegister darkgreen
125 HiLink groffRequest magenta
126 HiLink groffSpecialChar darkcyan
127 HiLink groffUnit brown
128 HiLink momCommentRegion darkcyan
130 HiLink momRegister green
131 HiLink momRegisterStart magenta
132 HiLink momSpecialParam red
133 HiLink momString white
134 HiLink startRequest yellow
138 let b:current_syntax = "mom"
140 " vim:ts=8:sw=4:nocindent:smartindent: