1071d4279SBram Moolenaar" Vim syntax file 2071d4279SBram Moolenaar" Language: Makefile 3ade0d394SBram Moolenaar" Maintainer: Roland Hieber <[email protected]>, <https://github.com/rohieb> 44c92e75dSBram Moolenaar" Previous Maintainer: Claudio Fleiner <[email protected]> 5ade0d394SBram Moolenaar" URL: https://github.com/vim/vim/blob/master/runtime/syntax/make.vim 6*2cfb4a2aSBram Moolenaar" Last Change: 2020 May 03 7071d4279SBram Moolenaar 889bcfda6SBram Moolenaar" quit when a syntax file was already loaded 989bcfda6SBram Moolenaarif exists("b:current_syntax") 10071d4279SBram Moolenaar finish 11071d4279SBram Moolenaarendif 12071d4279SBram Moolenaar 130c5fa7d7SBram Moolenaarlet s:cpo_save = &cpo 140c5fa7d7SBram Moolenaarset cpo&vim 150c5fa7d7SBram Moolenaar 16071d4279SBram Moolenaar" some special characters 178dff818eSBram Moolenaarsyn match makeSpecial "^\s*[@+-]\+" 18071d4279SBram Moolenaarsyn match makeNextLine "\\\n\s*" 19071d4279SBram Moolenaar 200c5fa7d7SBram Moolenaar" catch unmatched define/endef keywords. endef only matches it is by itself on a line, possibly followed by a commend 21b17893aaSBram Moolenaarsyn region makeDefine start="^\s*define\s" end="^\s*endef\s*\(#.*\)\?$" 22b17893aaSBram Moolenaar \ contains=makeStatement,makeIdent,makePreCondit,makeDefine 23071d4279SBram Moolenaar 24071d4279SBram Moolenaar" Microsoft Makefile specials 25071d4279SBram Moolenaarsyn case ignore 269834b968SBram Moolenaarsyn match makeInclude "^!\s*include\s.*$" 27723dd946SBram Moolenaarsyn match makePreCondit "^!\s*\(cmdswitches\|error\|message\|include\|if\|ifdef\|ifndef\|else\|else\s*if\|else\s*ifdef\|else\s*ifndef\|endif\|undef\)\>" 28071d4279SBram Moolenaarsyn case match 29071d4279SBram Moolenaar 30071d4279SBram Moolenaar" identifiers 319834b968SBram Moolenaarsyn region makeIdent start="\$(" skip="\\)\|\\\\" end=")" contains=makeStatement,makeIdent 329834b968SBram Moolenaarsyn region makeIdent start="\${" skip="\\}\|\\\\" end="}" contains=makeStatement,makeIdent 33071d4279SBram Moolenaarsyn match makeIdent "\$\$\w*" 34071d4279SBram Moolenaarsyn match makeIdent "\$[^({]" 352b8388bdSBram Moolenaarsyn match makeIdent "^ *[^:#= \t]*\s*[:+?!*]="me=e-2 36ade0d394SBram Moolenaarsyn match makeIdent "^ *[^:#= \t]*\s*::="me=e-3 372b8388bdSBram Moolenaarsyn match makeIdent "^ *[^:#= \t]*\s*="me=e-1 38071d4279SBram Moolenaarsyn match makeIdent "%" 39071d4279SBram Moolenaar 40071d4279SBram Moolenaar" Makefile.in variables 41071d4279SBram Moolenaarsyn match makeConfig "@[A-Za-z0-9_]\+@" 42071d4279SBram Moolenaar 43071d4279SBram Moolenaar" make targets 449834b968SBram Moolenaarsyn match makeImplicit "^\.[A-Za-z0-9_./\t -]\+\s*:$"me=e-1 459834b968SBram Moolenaarsyn match makeImplicit "^\.[A-Za-z0-9_./\t -]\+\s*:[^=]"me=e-2 46071d4279SBram Moolenaar 47b17893aaSBram Moolenaarsyn region makeTarget transparent matchgroup=makeTarget 48b17893aaSBram Moolenaar \ start="^[~A-Za-z0-9_./$()%-][A-Za-z0-9_./\t $()%-]*:\{1,2}[^:=]"rs=e-1 49b17893aaSBram Moolenaar \ end=";"re=e-1,me=e-1 end="[^\\]$" 50b17893aaSBram Moolenaar \ keepend contains=makeIdent,makeSpecTarget,makeNextLine,makeComment,makeDString 51b17893aaSBram Moolenaar \ skipnl nextGroup=makeCommands 52b17893aaSBram Moolenaarsyn match makeTarget "^[~A-Za-z0-9_./$()%*@-][A-Za-z0-9_./\t $()%*@-]*::\=\s*$" 53b17893aaSBram Moolenaar \ contains=makeIdent,makeSpecTarget,makeComment 54b17893aaSBram Moolenaar \ skipnl nextgroup=makeCommands,makeCommandError 55071d4279SBram Moolenaar 56b17893aaSBram Moolenaarsyn region makeSpecTarget transparent matchgroup=makeSpecTarget 57b17893aaSBram Moolenaar \ 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 58b17893aaSBram Moolenaar \ end="[^\\]$" keepend 59b17893aaSBram Moolenaar \ contains=makeIdent,makeSpecTarget,makeNextLine,makeComment skipnl nextGroup=makeCommands 60b17893aaSBram Moolenaarsyn match makeSpecTarget "^\.\(SUFFIXES\|PHONY\|DEFAULT\|PRECIOUS\|IGNORE\|SILENT\|EXPORT_ALL_VARIABLES\|KEEP_STATE\|LIBPATTERNS\|NOTPARALLEL\|DELETE_ON_ERROR\|INTERMEDIATE\|POSIX\|SECONDARY\)\>\s*::\=\s*$" 61b17893aaSBram Moolenaar \ contains=makeIdent,makeComment 62b17893aaSBram Moolenaar \ skipnl nextgroup=makeCommands,makeCommandError 63071d4279SBram Moolenaar 64071d4279SBram Moolenaarsyn match makeCommandError "^\s\+\S.*" contained 65b17893aaSBram Moolenaarsyn region makeCommands contained start=";"hs=s+1 start="^\t" 66b17893aaSBram Moolenaar \ end="^[^\t#]"me=e-1,re=e-1 end="^$" 67b17893aaSBram Moolenaar \ contains=makeCmdNextLine,makeSpecial,makeComment,makeIdent,makePreCondit,makeDefine,makeDString,makeSString 68b17893aaSBram Moolenaar \ nextgroup=makeCommandError 69071d4279SBram Moolenaarsyn match makeCmdNextLine "\\\n."he=e-1 contained 70071d4279SBram Moolenaar 71b17893aaSBram Moolenaar" some directives 72b17893aaSBram Moolenaarsyn match makePreCondit "^ *\(ifn\=\(eq\|def\)\>\|else\(\s\+ifn\=\(eq\|def\)\)\=\>\|endif\>\)" 73b17893aaSBram Moolenaarsyn match makeInclude "^ *[-s]\=include\s.*$" 74b17893aaSBram Moolenaarsyn match makeStatement "^ *vpath" 75b17893aaSBram Moolenaarsyn match makeExport "^ *\(export\|unexport\)\>" 76*2cfb4a2aSBram Moolenaarsyn match makeOverride "^ *override\>" 77071d4279SBram Moolenaar" Statements / Functions (GNU make) 784c92e75dSBram Moolenaarsyn 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 79071d4279SBram Moolenaar 80071d4279SBram Moolenaar" Comment 81071d4279SBram Moolenaarif exists("make_microsoft") 829964e468SBram Moolenaar syn match makeComment "#.*" contains=@Spell,makeTodo 838dff818eSBram Moolenaarelseif !exists("make_no_comments") 849964e468SBram Moolenaar syn region makeComment start="#" end="^$" end="[^\\]$" keepend contains=@Spell,makeTodo 859964e468SBram Moolenaar syn match makeComment "#$" contains=@Spell 86071d4279SBram Moolenaarendif 87071d4279SBram Moolenaarsyn keyword makeTodo TODO FIXME XXX contained 88071d4279SBram Moolenaar 89071d4279SBram Moolenaar" match escaped quotes and any other escaped character 90071d4279SBram Moolenaar" except for $, as a backslash in front of a $ does 91071d4279SBram Moolenaar" not make it a standard character, but instead it will 92071d4279SBram Moolenaar" still act as the beginning of a variable 93071d4279SBram Moolenaar" The escaped char is not highlightet currently 94071d4279SBram Moolenaarsyn match makeEscapedChar "\\[^$]" 95071d4279SBram Moolenaar 96071d4279SBram Moolenaar 979834b968SBram Moolenaarsyn region makeDString start=+\(\\\)\@<!"+ skip=+\\.+ end=+"+ contained contains=makeIdent 989834b968SBram Moolenaarsyn region makeSString start=+\(\\\)\@<!'+ skip=+\\.+ end=+'+ contained contains=makeIdent 99071d4279SBram Moolenaarsyn region makeBString start=+\(\\\)\@<!`+ skip=+\\.+ end=+`+ contains=makeIdent,makeSString,makeDString,makeNextLine 100071d4279SBram Moolenaar 101071d4279SBram Moolenaar" Syncing 102071d4279SBram Moolenaarsyn sync minlines=20 maxlines=200 103071d4279SBram Moolenaar 104071d4279SBram Moolenaar" Sync on Make command block region: When searching backwards hits a line that 105071d4279SBram Moolenaar" can't be a command or a comment, use makeCommands if it looks like a target, 106071d4279SBram Moolenaar" NONE otherwise. 107071d4279SBram Moolenaarsyn sync match makeCommandSync groupthere NONE "^[^\t#]" 108071d4279SBram Moolenaarsyn sync match makeCommandSync groupthere makeCommands "^[A-Za-z0-9_./$()%-][A-Za-z0-9_./\t $()%-]*:\{1,2}[^:=]" 109071d4279SBram Moolenaarsyn sync match makeCommandSync groupthere makeCommands "^[A-Za-z0-9_./$()%-][A-Za-z0-9_./\t $()%-]*:\{1,2}\s*$" 110071d4279SBram Moolenaar 111071d4279SBram Moolenaar" Define the default highlighting. 11289bcfda6SBram Moolenaar" Only when an item doesn't have highlighting yet 113071d4279SBram Moolenaar 114f37506f6SBram Moolenaarhi def link makeNextLine makeSpecial 115f37506f6SBram Moolenaarhi def link makeCmdNextLine makeSpecial 116b17893aaSBram Moolenaarhi link makeOverride makeStatement 117b17893aaSBram Moolenaarhi link makeExport makeStatement 118b17893aaSBram Moolenaar 119f37506f6SBram Moolenaarhi def link makeSpecTarget Statement 120071d4279SBram Moolenaarif !exists("make_no_commands") 121f37506f6SBram Moolenaarhi def link makeCommands Number 122071d4279SBram Moolenaarendif 123f37506f6SBram Moolenaarhi def link makeImplicit Function 124f37506f6SBram Moolenaarhi def link makeTarget Function 125f37506f6SBram Moolenaarhi def link makeInclude Include 126f37506f6SBram Moolenaarhi def link makePreCondit PreCondit 127f37506f6SBram Moolenaarhi def link makeStatement Statement 128f37506f6SBram Moolenaarhi def link makeIdent Identifier 129f37506f6SBram Moolenaarhi def link makeSpecial Special 130f37506f6SBram Moolenaarhi def link makeComment Comment 131f37506f6SBram Moolenaarhi def link makeDString String 132f37506f6SBram Moolenaarhi def link makeSString String 133f37506f6SBram Moolenaarhi def link makeBString Function 134f37506f6SBram Moolenaarhi def link makeError Error 135f37506f6SBram Moolenaarhi def link makeTodo Todo 136f37506f6SBram Moolenaarhi def link makeDefine Define 137f37506f6SBram Moolenaarhi def link makeCommandError Error 138f37506f6SBram Moolenaarhi def link makeConfig PreCondit 139071d4279SBram Moolenaar 140071d4279SBram Moolenaarlet b:current_syntax = "make" 141071d4279SBram Moolenaar 1420c5fa7d7SBram Moolenaarlet &cpo = s:cpo_save 1430c5fa7d7SBram Moolenaarunlet s:cpo_save 144071d4279SBram Moolenaar" vim: ts=8 145