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