blob: f90197aeb05bc7fad9c47d40afba32f130d0f31f [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 Moolenaar6ba83ba2022-06-12 22:15:57 +01005" (outdated)
6" Last Change: 2022 Jun 12
Bram Moolenaar071d4272004-06-13 20:20:40 +00007
8" This file will highlight user function calls if they use only
9" capital letters and have at least one argument (i.e. the '('
10" must be there). Let me know if this is a problem.
11
Bram Moolenaar89bcfda2016-08-30 23:26:57 +020012" quit when a syntax file was already loaded
Bram Moolenaar071d4272004-06-13 20:20:40 +000013if !exists("main_syntax")
Bram Moolenaar89bcfda2016-08-30 23:26:57 +020014 if exists("b:current_syntax")
15 finish
16 endif
17 " we define it here so that included files can test for it
Bram Moolenaar071d4272004-06-13 20:20:40 +000018 let main_syntax='m4'
19endif
20
21" define the m4 syntax
22syn match m4Variable contained "\$\d\+"
23syn match m4Special contained "$[@*#]"
Bram Moolenaar8ada17c2006-01-19 22:16:24 +000024syn match m4Comment "\<\(m4_\)\=dnl\>.*" contains=SpellErrors
Bram Moolenaar63f32602022-06-09 20:45:54 +010025syn match m4Comment "#.*" contains=SpellErrors
Bram Moolenaar8ada17c2006-01-19 22:16:24 +000026syn match m4Constants "\<\(m4_\)\=__file__"
27syn match m4Constants "\<\(m4_\)\=__line__"
Bram Moolenaar071d4272004-06-13 20:20:40 +000028syn keyword m4Constants divnum sysval m4_divnum m4_sysval
29syn region m4Paren matchgroup=m4Delimiter start="(" end=")" contained contains=@m4Top
30syn region m4Command matchgroup=m4Function start="\<\(m4_\)\=\(define\|defn\|pushdef\)(" end=")" contains=@m4Top
31syn region m4Command matchgroup=m4Preproc start="\<\(m4_\)\=\(include\|sinclude\)("he=e-1 end=")" contains=@m4Top
32syn 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
33syn region m4Command matchgroup=m4builtin start="\<\(m4_\)\=\(len\|index\|regexp\|substr\|translit\|patsubst\|format\|incr\|decr\|eval\|maketemp\)("he=e-1 end=")" contains=@m4Top
34syn keyword m4Statement divert undivert
35syn region m4Command matchgroup=m4Type start="\<\(m4_\)\=\(undefine\|popdef\)("he=e-1 end=")" contains=@m4Top
36syn region m4Function matchgroup=m4Type start="\<[_A-Z][_A-Z0-9]*("he=e-1 end=")" contains=@m4Top
Bram Moolenaar63f32602022-06-09 20:45:54 +010037syn region m4String start="`" end="'" contains=SpellErrors
Bram Moolenaar071d4272004-06-13 20:20:40 +000038syn cluster m4Top contains=m4Comment,m4Constants,m4Special,m4Variable,m4String,m4Paren,m4Command,m4Statement,m4Function
39
40" Define the default highlighting.
Bram Moolenaar89bcfda2016-08-30 23:26:57 +020041" Only when an item doesn't have highlighting yet
Bram Moolenaarf37506f2016-08-31 22:22:10 +020042hi def link m4Delimiter Delimiter
43hi def link m4Comment Comment
44hi def link m4Function Function
45hi def link m4Keyword Keyword
46hi def link m4Special Special
47hi def link m4String String
48hi def link m4Statement Statement
49hi def link m4Preproc PreProc
50hi def link m4Type Type
51hi def link m4Special Special
52hi def link m4Variable Special
53hi def link m4Constants Constant
54hi def link m4Builtin Statement
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