blob: ba7a294d14fa0e1d1d0b7a4282aeadcb2d804c10 [file] [log] [blame]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001" Vim syntax file
2" Language: M4
Bram Moolenaar8ada17c2006-01-19 22:16:24 +00003" Maintainer: Claudio Fleiner (claudio@fleiner.com)
Bram Moolenaar071d4272004-06-13 20:20:40 +00004" URL: http://www.fleiner.com/vim/syntax/m4.vim
Bram Moolenaar8ada17c2006-01-19 22:16:24 +00005" Last Change: 2005 Jan 15
Bram Moolenaar071d4272004-06-13 20:20:40 +00006
7" This file will highlight user function calls if they use only
8" capital letters and have at least one argument (i.e. the '('
9" must be there). Let me know if this is a problem.
10
11" For version 5.x: Clear all syntax items
12" For version 6.x: Quit when a syntax file was already loaded
13if !exists("main_syntax")
14 if version < 600
15 syntax clear
16 elseif exists("b:current_syntax")
17 finish
18endif
19" we define it here so that included files can test for it
20 let main_syntax='m4'
21endif
22
23" define the m4 syntax
24syn match m4Variable contained "\$\d\+"
25syn match m4Special contained "$[@*#]"
Bram Moolenaar8ada17c2006-01-19 22:16:24 +000026syn match m4Comment "\<\(m4_\)\=dnl\>.*" contains=SpellErrors
27syn match m4Constants "\<\(m4_\)\=__file__"
28syn match m4Constants "\<\(m4_\)\=__line__"
Bram Moolenaar071d4272004-06-13 20:20:40 +000029syn keyword m4Constants divnum sysval m4_divnum m4_sysval
30syn region m4Paren matchgroup=m4Delimiter start="(" end=")" contained contains=@m4Top
31syn region m4Command matchgroup=m4Function start="\<\(m4_\)\=\(define\|defn\|pushdef\)(" end=")" contains=@m4Top
32syn region m4Command matchgroup=m4Preproc start="\<\(m4_\)\=\(include\|sinclude\)("he=e-1 end=")" contains=@m4Top
33syn region m4Command matchgroup=m4Statement start="\<\(m4_\)\=\(syscmd\|esyscmd\|ifdef\|ifelse\|indir\|builtin\|shift\|errprint\|m4exit\|changecom\|changequote\|changeword\|m4wrap\|debugfile\|divert\|undivert\)("he=e-1 end=")" contains=@m4Top
34syn region m4Command matchgroup=m4builtin start="\<\(m4_\)\=\(len\|index\|regexp\|substr\|translit\|patsubst\|format\|incr\|decr\|eval\|maketemp\)("he=e-1 end=")" contains=@m4Top
35syn keyword m4Statement divert undivert
36syn region m4Command matchgroup=m4Type start="\<\(m4_\)\=\(undefine\|popdef\)("he=e-1 end=")" contains=@m4Top
37syn region m4Function matchgroup=m4Type start="\<[_A-Z][_A-Z0-9]*("he=e-1 end=")" contains=@m4Top
38syn region m4String start="`" end="'" contained contains=@m4Top,@m4StringContents,SpellErrors
39syn cluster m4Top contains=m4Comment,m4Constants,m4Special,m4Variable,m4String,m4Paren,m4Command,m4Statement,m4Function
40
41" Define the default highlighting.
42" For version 5.7 and earlier: only when not done already
43" For version 5.8 and later: only when an item doesn't have highlighting yet
44if version >= 508 || !exists("did_m4_syn_inits")
45 if version < 508
46 let did_m4_syn_inits = 1
47 command -nargs=+ HiLink hi link <args>
48 else
49 command -nargs=+ HiLink hi def link <args>
50 endif
51 HiLink m4Delimiter Delimiter
52 HiLink m4Comment Comment
53 HiLink m4Function Function
54 HiLink m4Keyword Keyword
55 HiLink m4Special Special
56 HiLink m4String String
57 HiLink m4Statement Statement
58 HiLink m4Preproc PreProc
59 HiLink m4Type Type
60 HiLink m4Special Special
61 HiLink m4Variable Special
62 HiLink m4Constants Constant
63 HiLink m4Builtin Statement
64 delcommand HiLink
65endif
66
67let b:current_syntax = "m4"
68
69if main_syntax == 'm4'
70 unlet main_syntax
71endif
72
73" vim: ts=4