blob: 8325405261e6b6a909bfc11e824f4df87f7ea28a [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
Bram Moolenaar89bcfda2016-08-30 23:26:57 +020011" quit when a syntax file was already loaded
Bram Moolenaar071d4272004-06-13 20:20:40 +000012if !exists("main_syntax")
Bram Moolenaar89bcfda2016-08-30 23:26:57 +020013 if exists("b:current_syntax")
14 finish
15 endif
16 " we define it here so that included files can test for it
Bram Moolenaar071d4272004-06-13 20:20:40 +000017 let main_syntax='m4'
18endif
19
20" define the m4 syntax
21syn match m4Variable contained "\$\d\+"
22syn match m4Special contained "$[@*#]"
Bram Moolenaar8ada17c2006-01-19 22:16:24 +000023syn match m4Comment "\<\(m4_\)\=dnl\>.*" contains=SpellErrors
24syn match m4Constants "\<\(m4_\)\=__file__"
25syn match m4Constants "\<\(m4_\)\=__line__"
Bram Moolenaar071d4272004-06-13 20:20:40 +000026syn keyword m4Constants divnum sysval m4_divnum m4_sysval
27syn region m4Paren matchgroup=m4Delimiter start="(" end=")" contained contains=@m4Top
28syn region m4Command matchgroup=m4Function start="\<\(m4_\)\=\(define\|defn\|pushdef\)(" end=")" contains=@m4Top
29syn region m4Command matchgroup=m4Preproc start="\<\(m4_\)\=\(include\|sinclude\)("he=e-1 end=")" contains=@m4Top
30syn 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
31syn region m4Command matchgroup=m4builtin start="\<\(m4_\)\=\(len\|index\|regexp\|substr\|translit\|patsubst\|format\|incr\|decr\|eval\|maketemp\)("he=e-1 end=")" contains=@m4Top
32syn keyword m4Statement divert undivert
33syn region m4Command matchgroup=m4Type start="\<\(m4_\)\=\(undefine\|popdef\)("he=e-1 end=")" contains=@m4Top
34syn region m4Function matchgroup=m4Type start="\<[_A-Z][_A-Z0-9]*("he=e-1 end=")" contains=@m4Top
35syn region m4String start="`" end="'" contained contains=@m4Top,@m4StringContents,SpellErrors
36syn cluster m4Top contains=m4Comment,m4Constants,m4Special,m4Variable,m4String,m4Paren,m4Command,m4Statement,m4Function
37
38" Define the default highlighting.
Bram Moolenaar89bcfda2016-08-30 23:26:57 +020039" Only when an item doesn't have highlighting yet
40command -nargs=+ HiLink hi def link <args>
41HiLink m4Delimiter Delimiter
42HiLink m4Comment Comment
43HiLink m4Function Function
44HiLink m4Keyword Keyword
45HiLink m4Special Special
46HiLink m4String String
47HiLink m4Statement Statement
48HiLink m4Preproc PreProc
49HiLink m4Type Type
50HiLink m4Special Special
51HiLink m4Variable Special
52HiLink m4Constants Constant
53HiLink m4Builtin Statement
54delcommand HiLink
Bram Moolenaar071d4272004-06-13 20:20:40 +000055
56let b:current_syntax = "m4"
57
58if main_syntax == 'm4'
59 unlet main_syntax
60endif
61
62" vim: ts=4