3 " Maintainer: Claudio Fleiner (claudio@fleiner.com)
4 " URL: http://www.fleiner.com/vim/syntax/m4.vim
5 " Last Change: 2005 Jan 15
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.
11 " For version 5.x: Clear all syntax items
12 " For version 6.x: Quit when a syntax file was already loaded
13 if !exists("main_syntax")
16 elseif exists("b:current_syntax")
19 " we define it here so that included files can test for it
23 " define the m4 syntax
24 syn match m4Variable contained "\$\d\+"
25 syn match m4Special contained "$[@*#]"
26 syn match m4Comment "\<\(m4_\)\=dnl\>.*" contains=SpellErrors
27 syn match m4Constants "\<\(m4_\)\=__file__"
28 syn match m4Constants "\<\(m4_\)\=__line__"
29 syn keyword m4Constants divnum sysval m4_divnum m4_sysval
30 syn region m4Paren matchgroup=m4Delimiter start="(" end=")" contained contains=@m4Top
31 syn region m4Command matchgroup=m4Function start="\<\(m4_\)\=\(define\|defn\|pushdef\)(" end=")" contains=@m4Top
32 syn region m4Command matchgroup=m4Preproc start="\<\(m4_\)\=\(include\|sinclude\)("he=e-1 end=")" contains=@m4Top
33 syn 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
34 syn region m4Command matchgroup=m4builtin start="\<\(m4_\)\=\(len\|index\|regexp\|substr\|translit\|patsubst\|format\|incr\|decr\|eval\|maketemp\)("he=e-1 end=")" contains=@m4Top
35 syn keyword m4Statement divert undivert
36 syn region m4Command matchgroup=m4Type start="\<\(m4_\)\=\(undefine\|popdef\)("he=e-1 end=")" contains=@m4Top
37 syn region m4Function matchgroup=m4Type start="\<[_A-Z][_A-Z0-9]*("he=e-1 end=")" contains=@m4Top
38 syn region m4String start="`" end="'" contained contains=@m4Top,@m4StringContents,SpellErrors
39 syn cluster m4Top contains=m4Comment,m4Constants,m4Special,m4Variable,m4String,m4Paren,m4Command,m4Statement,m4Function
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
44 if version >= 508 || !exists("did_m4_syn_inits")
46 let did_m4_syn_inits = 1
47 command -nargs=+ HiLink hi link <args>
49 command -nargs=+ HiLink hi def link <args>
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
60 HiLink m4Special Special
61 HiLink m4Variable Special
62 HiLink m4Constants Constant
63 HiLink m4Builtin Statement
67 let b:current_syntax = "m4"
69 if main_syntax == 'm4'