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