1" Vim syntax file 2" Language: Makefile 3" Maintainer: Roland Hieber <[email protected]> 4" Previous Maintainer: Claudio Fleiner <[email protected]> 5" URL: https://github.com/vim/vim/syntax/make.vim 6" Last Change: 2019 Dec 04 7 8" quit when a syntax file was already loaded 9if exists("b:current_syntax") 10 finish 11endif 12 13let s:cpo_save = &cpo 14set cpo&vim 15 16 17" some special characters 18syn match makeSpecial "^\s*[@+-]\+" 19syn match makeNextLine "\\\n\s*" 20 21" some directives 22syn match makePreCondit "^ *\(ifn\=\(eq\|def\)\>\|else\(\s\+ifn\=\(eq\|def\)\)\=\>\|endif\>\)" 23syn match makeInclude "^ *[-s]\=include\s.*$" 24syn match makeStatement "^ *vpath" 25syn match makeExport "^ *\(export\|unexport\)\>" 26syn match makeOverride "^ *override" 27hi link makeOverride makeStatement 28hi link makeExport makeStatement 29 30" catch unmatched define/endef keywords. endef only matches it is by itself on a line, possibly followed by a commend 31syn region makeDefine start="^\s*define\s" end="^\s*endef\s*\(#.*\)\?$" contains=makeStatement,makeIdent,makePreCondit,makeDefine 32 33" Microsoft Makefile specials 34syn case ignore 35syn match makeInclude "^!\s*include\s.*$" 36syn match makePreCondit "^!\s*\(cmdswitches\|error\|message\|include\|if\|ifdef\|ifndef\|else\|else\s*if\|else\s*ifdef\|else\s*ifndef\|endif\|undef\)\>" 37syn case match 38 39" identifiers 40syn region makeIdent start="\$(" skip="\\)\|\\\\" end=")" contains=makeStatement,makeIdent 41syn region makeIdent start="\${" skip="\\}\|\\\\" end="}" contains=makeStatement,makeIdent 42syn match makeIdent "\$\$\w*" 43syn match makeIdent "\$[^({]" 44syn match makeIdent "^ *[^:#= \t]*\s*[:+?!*]="me=e-2 45syn match makeIdent "^ *[^:#= \t]*\s*="me=e-1 46syn match makeIdent "%" 47 48" Makefile.in variables 49syn match makeConfig "@[A-Za-z0-9_]\+@" 50 51" make targets 52syn match makeImplicit "^\.[A-Za-z0-9_./\t -]\+\s*:$"me=e-1 53syn match makeImplicit "^\.[A-Za-z0-9_./\t -]\+\s*:[^=]"me=e-2 54 55syn region makeTarget transparent matchgroup=makeTarget start="^[~A-Za-z0-9_./$()%-][A-Za-z0-9_./\t $()%-]*:\{1,2}[^:=]"rs=e-1 end=";"re=e-1,me=e-1 end="[^\\]$" keepend contains=makeIdent,makeSpecTarget,makeNextLine,makeComment,makeDString skipnl nextGroup=makeCommands 56syn match makeTarget "^[~A-Za-z0-9_./$()%*@-][A-Za-z0-9_./\t $()%*@-]*::\=\s*$" contains=makeIdent,makeSpecTarget,makeComment skipnl nextgroup=makeCommands,makeCommandError 57 58syn region makeSpecTarget transparent matchgroup=makeSpecTarget start="^\.\(SUFFIXES\|PHONY\|DEFAULT\|PRECIOUS\|IGNORE\|SILENT\|EXPORT_ALL_VARIABLES\|KEEP_STATE\|LIBPATTERNS\|NOTPARALLEL\|DELETE_ON_ERROR\|INTERMEDIATE\|POSIX\|SECONDARY\)\>\s*:\{1,2}[^:=]"rs=e-1 end="[^\\]$" keepend contains=makeIdent,makeSpecTarget,makeNextLine,makeComment skipnl nextGroup=makeCommands 59syn match makeSpecTarget "^\.\(SUFFIXES\|PHONY\|DEFAULT\|PRECIOUS\|IGNORE\|SILENT\|EXPORT_ALL_VARIABLES\|KEEP_STATE\|LIBPATTERNS\|NOTPARALLEL\|DELETE_ON_ERROR\|INTERMEDIATE\|POSIX\|SECONDARY\)\>\s*::\=\s*$" contains=makeIdent,makeComment skipnl nextgroup=makeCommands,makeCommandError 60 61syn match makeCommandError "^\s\+\S.*" contained 62syn region makeCommands start=";"hs=s+1 start="^\t" end="^[^\t#]"me=e-1,re=e-1 end="^$" contained contains=makeCmdNextLine,makeSpecial,makeComment,makeIdent,makePreCondit,makeDefine,makeDString,makeSString nextgroup=makeCommandError 63syn match makeCmdNextLine "\\\n."he=e-1 contained 64 65 66" Statements / Functions (GNU make) 67syn match makeStatement contained "(\(abspath\|addprefix\|addsuffix\|and\|basename\|call\|dir\|error\|eval\|file\|filter-out\|filter\|findstring\|firstword\|flavor\|foreach\|guile\|if\|info\|join\|lastword\|notdir\|or\|origin\|patsubst\|realpath\|shell\|sort\|strip\|subst\|suffix\|value\|warning\|wildcard\|word\|wordlist\|words\)\>"ms=s+1 68 69" Comment 70if exists("make_microsoft") 71 syn match makeComment "#.*" contains=@Spell,makeTodo 72elseif !exists("make_no_comments") 73 syn region makeComment start="#" end="^$" end="[^\\]$" keepend contains=@Spell,makeTodo 74 syn match makeComment "#$" contains=@Spell 75endif 76syn keyword makeTodo TODO FIXME XXX contained 77 78" match escaped quotes and any other escaped character 79" except for $, as a backslash in front of a $ does 80" not make it a standard character, but instead it will 81" still act as the beginning of a variable 82" The escaped char is not highlightet currently 83syn match makeEscapedChar "\\[^$]" 84 85 86syn region makeDString start=+\(\\\)\@<!"+ skip=+\\.+ end=+"+ contained contains=makeIdent 87syn region makeSString start=+\(\\\)\@<!'+ skip=+\\.+ end=+'+ contained contains=makeIdent 88syn region makeBString start=+\(\\\)\@<!`+ skip=+\\.+ end=+`+ contains=makeIdent,makeSString,makeDString,makeNextLine 89 90" Syncing 91syn sync minlines=20 maxlines=200 92 93" Sync on Make command block region: When searching backwards hits a line that 94" can't be a command or a comment, use makeCommands if it looks like a target, 95" NONE otherwise. 96syn sync match makeCommandSync groupthere NONE "^[^\t#]" 97syn sync match makeCommandSync groupthere makeCommands "^[A-Za-z0-9_./$()%-][A-Za-z0-9_./\t $()%-]*:\{1,2}[^:=]" 98syn sync match makeCommandSync groupthere makeCommands "^[A-Za-z0-9_./$()%-][A-Za-z0-9_./\t $()%-]*:\{1,2}\s*$" 99 100" Define the default highlighting. 101" Only when an item doesn't have highlighting yet 102 103hi def link makeNextLine makeSpecial 104hi def link makeCmdNextLine makeSpecial 105hi def link makeSpecTarget Statement 106if !exists("make_no_commands") 107hi def link makeCommands Number 108endif 109hi def link makeImplicit Function 110hi def link makeTarget Function 111hi def link makeInclude Include 112hi def link makePreCondit PreCondit 113hi def link makeStatement Statement 114hi def link makeIdent Identifier 115hi def link makeSpecial Special 116hi def link makeComment Comment 117hi def link makeDString String 118hi def link makeSString String 119hi def link makeBString Function 120hi def link makeError Error 121hi def link makeTodo Todo 122hi def link makeDefine Define 123hi def link makeCommandError Error 124hi def link makeConfig PreCondit 125 126let b:current_syntax = "make" 127 128let &cpo = s:cpo_save 129unlet s:cpo_save 130" vim: ts=8 131