1 " ninja build file syntax.
2 " Language: ninja build file as described at
3 " http://martine.github.com/ninja/manual.html
5 " Last Change: 2014/05/13
6 " Maintainer: Nicolas Weber <nicolasweber@gmx.de>
7 " Version 1.4 of this script is in the upstream vim repository and will be
8 " included in the next vim release. If you change this, please send your change
11 " ninja lexer and parser are at
12 " https://github.com/martine/ninja/blob/master/src/lexer.in.cc
13 " https://github.com/martine/ninja/blob/master/src/manifest_parser.cc
15 if exists("b:current_syntax")
24 syn match ninjaComment /#.*/ contains=@Spell
26 " Toplevel statements are the ones listed here and
27 " toplevel variable assignments (ident '=' value).
28 " lexer.in.cc, ReadToken() and manifest_parser.cc, Parse()
29 syn match ninjaKeyword "^build\>"
30 syn match ninjaKeyword "^rule\>"
31 syn match ninjaKeyword "^pool\>"
32 syn match ninjaKeyword "^default\>"
33 syn match ninjaKeyword "^include\>"
34 syn match ninjaKeyword "^subninja\>"
36 " Both 'build' and 'rule' begin a variable scope that ends
37 " on the first line without indent. 'rule' allows only a
38 " limited set of magic variables, 'build' allows general
40 " manifest_parser.cc, ParseRule()
41 syn region ninjaRule start="^rule" end="^\ze\S" contains=ALL transparent
42 syn keyword ninjaRuleCommand contained command deps depfile description generator
43 \ pool restat rspfile rspfile_content
45 syn region ninjaPool start="^pool" end="^\ze\S" contains=ALL transparent
46 syn keyword ninjaPoolCommand contained depth
48 " Strings are parsed as follows:
49 " lexer.in.cc, ReadEvalString()
50 " simple_varname = [a-zA-Z0-9_-]+;
51 " varname = [a-zA-Z0-9_.-]+;
53 " $\n -> line continuation
54 " '$ ' -> escaped space
55 " $simple_varname -> variable
56 " ${varname} -> variable
58 syn match ninjaDollar "\$\$"
59 syn match ninjaWrapLineOperator "\$$"
60 syn match ninjaSimpleVar "\$[a-zA-Z0-9_-]\+"
61 syn match ninjaVar "\${[a-zA-Z0-9_.-]\+}"
64 " variable assignment =
66 " implicit dependency |
67 " order-only dependency ||
68 syn match ninjaOperator "\(=\|:\||\|||\)\ze\s"
70 hi def link ninjaComment Comment
71 hi def link ninjaKeyword Keyword
72 hi def link ninjaRuleCommand Statement
73 hi def link ninjaPoolCommand Statement
74 hi def link ninjaDollar ninjaOperator
75 hi def link ninjaWrapLineOperator ninjaOperator
76 hi def link ninjaOperator Operator
77 hi def link ninjaSimpleVar ninjaVar
78 hi def link ninjaVar Identifier
80 let b:current_syntax = "ninja"