Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 1 | " Vim syntax file |
| 2 | " Language: M4 |
Bram Moolenaar | 8ada17c | 2006-01-19 22:16:24 +0000 | [diff] [blame] | 3 | " Maintainer: Claudio Fleiner (claudio@fleiner.com) |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 4 | " URL: http://www.fleiner.com/vim/syntax/m4.vim |
Bram Moolenaar | 8ada17c | 2006-01-19 22:16:24 +0000 | [diff] [blame] | 5 | " Last Change: 2005 Jan 15 |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 6 | |
| 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 Moolenaar | 89bcfda | 2016-08-30 23:26:57 +0200 | [diff] [blame] | 11 | " quit when a syntax file was already loaded |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 12 | if !exists("main_syntax") |
Bram Moolenaar | 89bcfda | 2016-08-30 23:26:57 +0200 | [diff] [blame] | 13 | if exists("b:current_syntax") |
| 14 | finish |
| 15 | endif |
| 16 | " we define it here so that included files can test for it |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 17 | let main_syntax='m4' |
| 18 | endif |
| 19 | |
| 20 | " define the m4 syntax |
| 21 | syn match m4Variable contained "\$\d\+" |
| 22 | syn match m4Special contained "$[@*#]" |
Bram Moolenaar | 8ada17c | 2006-01-19 22:16:24 +0000 | [diff] [blame] | 23 | syn match m4Comment "\<\(m4_\)\=dnl\>.*" contains=SpellErrors |
Bram Moolenaar | 63f3260 | 2022-06-09 20:45:54 +0100 | [diff] [blame] | 24 | syn match m4Comment "#.*" contains=SpellErrors |
Bram Moolenaar | 8ada17c | 2006-01-19 22:16:24 +0000 | [diff] [blame] | 25 | syn match m4Constants "\<\(m4_\)\=__file__" |
| 26 | syn match m4Constants "\<\(m4_\)\=__line__" |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 27 | syn keyword m4Constants divnum sysval m4_divnum m4_sysval |
| 28 | syn region m4Paren matchgroup=m4Delimiter start="(" end=")" contained contains=@m4Top |
| 29 | syn region m4Command matchgroup=m4Function start="\<\(m4_\)\=\(define\|defn\|pushdef\)(" end=")" contains=@m4Top |
| 30 | syn region m4Command matchgroup=m4Preproc start="\<\(m4_\)\=\(include\|sinclude\)("he=e-1 end=")" contains=@m4Top |
| 31 | 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 |
| 32 | syn region m4Command matchgroup=m4builtin start="\<\(m4_\)\=\(len\|index\|regexp\|substr\|translit\|patsubst\|format\|incr\|decr\|eval\|maketemp\)("he=e-1 end=")" contains=@m4Top |
| 33 | syn keyword m4Statement divert undivert |
| 34 | syn region m4Command matchgroup=m4Type start="\<\(m4_\)\=\(undefine\|popdef\)("he=e-1 end=")" contains=@m4Top |
| 35 | syn region m4Function matchgroup=m4Type start="\<[_A-Z][_A-Z0-9]*("he=e-1 end=")" contains=@m4Top |
Bram Moolenaar | 63f3260 | 2022-06-09 20:45:54 +0100 | [diff] [blame] | 36 | syn region m4String start="`" end="'" contains=SpellErrors |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 37 | syn cluster m4Top contains=m4Comment,m4Constants,m4Special,m4Variable,m4String,m4Paren,m4Command,m4Statement,m4Function |
| 38 | |
| 39 | " Define the default highlighting. |
Bram Moolenaar | 89bcfda | 2016-08-30 23:26:57 +0200 | [diff] [blame] | 40 | " Only when an item doesn't have highlighting yet |
Bram Moolenaar | f37506f | 2016-08-31 22:22:10 +0200 | [diff] [blame] | 41 | hi def link m4Delimiter Delimiter |
| 42 | hi def link m4Comment Comment |
| 43 | hi def link m4Function Function |
| 44 | hi def link m4Keyword Keyword |
| 45 | hi def link m4Special Special |
| 46 | hi def link m4String String |
| 47 | hi def link m4Statement Statement |
| 48 | hi def link m4Preproc PreProc |
| 49 | hi def link m4Type Type |
| 50 | hi def link m4Special Special |
| 51 | hi def link m4Variable Special |
| 52 | hi def link m4Constants Constant |
| 53 | hi def link m4Builtin Statement |
Bram Moolenaar | 071d427 | 2004-06-13 20:20:40 +0000 | [diff] [blame] | 54 | |
| 55 | let b:current_syntax = "m4" |
| 56 | |
| 57 | if main_syntax == 'm4' |
| 58 | unlet main_syntax |
| 59 | endif |
| 60 | |
| 61 | " vim: ts=4 |