Imported Upstream version 1.22.4
[platform/upstream/groff.git] / contrib / mom / examples / mom.vim
1 " Copyright (C) 2012-2018 Free Software Foundation, Inc.
2 "
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.
6
7 " Vim syntax file
8 " Language:    mom
9 " Maintainer:  Peter Schaffter (peter@schaffter.ca)
10 " Last Change: So 06 Mär 2005 17:28:13 CET
11 " Filenames:   *.mom
12 " URL:         http://www.cvjb.de/comp/vim/mom.vim
13 " Note:        Remove or overwrite troff syntax for *.mom-files with filetype/filedetect.
14 " Version:     0.1
15 "
16 " Mom: Macro set for easy typesetting with troff/nroff/groff.
17
18 " For version 5.x: Clear all syntax items
19 " For version 6.x: Quit when a syntax file was already loaded
20 if version < 600
21         syntax clear
22 elseif exists("b:current_syntax")
23         finish
24 endif
25
26 " Mom is case sensitive
27 syn case match
28
29 " Synchronization, I know it is a huge number, but normal texts can be
30 " _very_ long ;-)
31 syn sync lines=1000
32
33 " Characters allowed in keywords
34 if version >= 600
35         setlocal iskeyword=@,#,$,%,48-57,.,@-@,_,\\,{,},192-255
36 else
37         set iskeyword=@,#,$,%,48-57,.,@-@,_,\\,{,},192-255
38 endif
39
40 " mom/groff macros and requests (the initial dot or single-quote)
41 "
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
45
46 " mom macros
47 syn region momMacro start=/^\s*\(\.\|'\)\s*\zs[A-Z0-9_(){}\[\]]\+/ end=/\s\+\|$/
48
49 " mom registers and strings
50 syn match momRegister /\(\$\|#\)[A-Za-z][_0-9A-Za-z]*/ contains=momRegisterStart
51
52 syn match momRegisterStart /#\|\$/ contained
53
54 " mom comment region
55 syn region momCommentRegion matchgroup=startRequest start='\<\.\(COMMENT\)\|\(SILENT\)\>' end='\<\.\(COMMENT\s\+OFF\)\|\(SILENT\s\+OFF\)\>' skip='$'
56
57 " groff requests
58 syn match groffRequest /^\s*\(\.\|'\)\s*\zs[a-z0-9]\+/
59
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
63
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
67
68 " Preprocessor requests for refer
69 syn match groffPreprocessor /\(\[\s*$\|\]\s*$\)/ contained
70
71 " Quoted strings
72 syn region momString matchgroup=startRequest start='"\zs' end='"\|$' contains=groffNoLineBreak,groffGreek,groffSpecialChar,momInteger,momFloatEN,momFloatDE,momBracketRegion,momBracketError,momSpecialMove contained
73
74 " Special characters
75 syn match groffSpecialChar '\\\((\|\[\)[-+A-Za-z0-9*<>=~!\/]\+\]*'
76
77 " Greek symbols
78 syn match groffGreek '\\(\*[A-Za-z]\+'
79
80 " Hyphenation marks
81 syn match groffHyphenation '\\%'
82
83 " Masking of line breaks
84 syn match groffNoLineBreak /\\\s*$/ contains=groffBraces
85
86 " groff number and string register delimiters
87 syn region groffDelimiter start=/\\*\\\(n+*\|\*\)\((\|\[\)\</ end=/\(\s\|\]\|$\)/ contains=momRegister,groffRegister,groffOperators
88
89 " groff registers
90 syn match groffRegister /\\\((\|\[\)\zs\.*[a-z]\+/
91
92 " groff operators
93 syn match groffOperators /\(+\|-\|\/\|\*[^[]\)/ contained
94
95 " Units (of measure)
96 syn match groffUnit '[-+]\=\([0-9]\|]\)\+\zs[icPpvusfz]\=' contained
97
98 " Braces
99 syn match groffBraces /\(\\{\|\\}\)/ contained
100
101 " Error
102 syn match groffError '\\\[ \+[[:print:]]\+ \+[[:print:]]\+\]'
103
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")
107         if version < 508
108                 let did_mom_syn_inits = 1
109                 command -nargs=+ HiLink hi link <args>
110         else
111                 command -nargs=+ HiLink hi def link <args>
112         endif
113
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
129 HiLink momMacro                 red
130 HiLink momRegister              green
131 HiLink momRegisterStart         magenta
132 HiLink momSpecialParam          red
133 HiLink momString                white
134 HiLink startRequest             yellow
135         delcommand HiLink
136 endif
137
138 let b:current_syntax = "mom"
139
140 " vim:ts=8:sw=4:nocindent:smartindent: