3 " Maintainer: Claudio Fleiner <claudio@fleiner.com>
4 " URL: http://www.fleiner.com/vim/syntax/make.vim
5 " Last Change: 2001 Apr 26
7 " For version 5.x: Clear all syntax items
8 " For version 6.x: Quit when a syntax file was already loaded
11 elseif exists("b:current_syntax")
16 syn match makePreCondit "^\s*\(ifeq\>\|else\>\|endif\>\|define\>\|endef\>\|ifneq\>\|ifdef\>\|ifndef\>\)"
17 syn match makeInclude "^\s*include"
18 syn match makeStatement "^\s*vpath"
19 syn match makeOverride "^\s*override"
20 hi link makeOverride makeStatement
22 " Microsoft Makefile specials
24 syn match makeInclude "^!\s*include"
25 syn match makePreCondit "!\s*\(cmdswitches\>\|error\>\|message\>\|include\>\|if\>\|ifdef\>\|ifndef\>\|else\>\|elseif\>\|else if\>\|else\s*ifdef\>\|else\s*ifndef\>\|endif\>\|undef\>\)"
29 syn region makeIdent start="\$(" skip="\\)" end=")" contains=makeStatement,makeIdent
30 syn region makeIdent start="\${" skip="\\}" end="}" contains=makeStatement,makeIdent
31 syn match makeIdent "\$\$\w*"
32 syn match makeIdent "\$[^({]"
33 syn match makeIdent "^\s*\a\w*\s*[:+?!*]="me=e-2
34 syn match makeIdent "^\s*\a\w*\s*="me=e-1
35 syn match makeIdent "%"
39 syn match makeSpecTarget "^\.SUFFIXES"
40 syn match makeSpecTarget "^\.PHONY"
41 syn match makeSpecTarget "^\.DEFAULT"
42 syn match makeSpecTarget "^\.PRECIOUS"
43 syn match makeSpecTarget "^\.IGNORE"
44 syn match makeSpecTarget "^\.SILENT"
45 syn match makeSpecTarget "^\.EXPORT_ALL_VARIABLES"
46 syn match makeSpecTarget "^\.KEEP_STATE"
47 syn match makeSpecTarget "^\.LIBPATTERNS"
48 syn match makeSpecTarget "^\.NOTPARALLEL"
49 syn match makeImplicit "^\.[A-Za-z0-9_./\t -]\+\s*:[^=]"me=e-2
50 syn match makeImplicit "^\.[A-Za-z0-9_./\t -]\+\s*:$"me=e-1
51 syn match makeTarget "^[A-Za-z0-9_./$()%-][A-Za-z0-9_./\t $()%-]*:[^=]"me=e-2 contains=makeIdent,makeSpecTarget
52 syn match makeTarget "^[A-Za-z0-9_./$()%-][A-Za-z0-9_./\t $()%-]*:$"me=e-1 contains=makeIdent,makeSpecTarget
54 " Statements / Functions (GNU make)
55 syn match makeStatement contained "(\(subst\|addprefix\|addsuffix\|basename\|call\|dir\|error\|filter\|filter-out\|findstring\|firstword\|foreach\|if\|join\|notdir\|origin\|patsubst\|shell\|sort\|strip\|suffix\|warning\|wildcard\|word\|wordlist\|words\)\>"ms=s+1
57 " some special characters
58 syn match makeSpecial "^\s*[@-]\+"
59 syn match makeNextLine "\\$"
63 syn match makeError "^ \+\t"
64 syn match makeError "^ \{8\}[^ ]"me=e-1
65 syn region makeIgnore start="\\$" end="^." end="^$" contains=ALLBUT,makeError
68 syn region makeComment start="#" end="[^\\]$"
69 syn match makeComment "#$"
71 " match escaped quotes and any other escaped character
72 " except for $, as a backslash in front of a $ does
73 " not make it a standard character, but instead it will
74 " still act as the beginning of a variable
75 " The escaped char is not highlightet currently
76 syn match makeEscapedChar "\\[^$]"
79 syn region makeDString start=+"+ skip=+\\"+ end=+"+ contains=makeIdent
80 syn region makeSString start=+'+ skip=+\\'+ end=+'+ contains=makeIdent
81 syn region makeBString start=+`+ skip=+\\`+ end=+`+ contains=makeIdent,makeSString,makeDString,makeNextLine
83 " Define the default highlighting.
84 " For version 5.7 and earlier: only when not done already
85 " For version 5.8 and later: only when an item doesn't have highlighting yet
86 if version >= 508 || !exists("did_make_syn_inits")
88 let did_make_syn_inits = 1
89 command -nargs=+ HiLink hi link <args>
91 command -nargs=+ HiLink hi def link <args>
94 HiLink makeNextLine makeSpecial
95 HiLink makeSpecTarget Statement
96 HiLink makeImplicit Function
97 HiLink makeTarget Function
98 HiLink makeInclude Include
99 HiLink makePreCondit PreCondit
100 HiLink makeStatement Statement
101 HiLink makeIdent Identifier
102 HiLink makeSpecial Special
103 HiLink makeComment Comment
104 HiLink makeDString String
105 HiLink makeSString String
106 HiLink makeBString Function
107 HiLink makeError Error
111 let b:current_syntax = "make"