3256
|
1 " ninja build file syntax.
|
|
2 " Language: ninja build file as described at
|
13589
|
3 " http://ninja-build.org/manual.html
|
|
4 " Version: 1.5
|
|
5 " Last Change: 2018/04/05
|
3256
|
6 " Maintainer: Nicolas Weber <nicolasweber@gmx.de>
|
13589
|
7 " Version 1.5 of this script is in the upstream vim repository and will be
|
4339
|
8 " included in the next vim release. If you change this, please send your change
|
|
9 " upstream.
|
3256
|
10
|
|
11 " ninja lexer and parser are at
|
13589
|
12 " https://github.com/ninja-build/ninja/blob/master/src/lexer.in.cc
|
|
13 " https://github.com/ninja-build/ninja/blob/master/src/manifest_parser.cc
|
3256
|
14
|
|
15 if exists("b:current_syntax")
|
|
16 finish
|
|
17 endif
|
|
18
|
4339
|
19 let s:cpo_save = &cpo
|
|
20 set cpo&vim
|
|
21
|
3256
|
22 syn case match
|
|
23
|
13589
|
24 " Comments are only matched when the # is at the beginning of the line (with
|
|
25 " optional whitespace), as long as the prior line didn't end with a $
|
|
26 " continuation.
|
|
27 syn match ninjaComment /\(\$\n\)\@<!\_^\s*#.*$/ contains=@Spell
|
3513
|
28
|
3256
|
29 " Toplevel statements are the ones listed here and
|
|
30 " toplevel variable assignments (ident '=' value).
|
4278
|
31 " lexer.in.cc, ReadToken() and manifest_parser.cc, Parse()
|
3256
|
32 syn match ninjaKeyword "^build\>"
|
|
33 syn match ninjaKeyword "^rule\>"
|
4278
|
34 syn match ninjaKeyword "^pool\>"
|
3256
|
35 syn match ninjaKeyword "^default\>"
|
|
36 syn match ninjaKeyword "^include\>"
|
|
37 syn match ninjaKeyword "^subninja\>"
|
|
38
|
|
39 " Both 'build' and 'rule' begin a variable scope that ends
|
|
40 " on the first line without indent. 'rule' allows only a
|
|
41 " limited set of magic variables, 'build' allows general
|
|
42 " let assignments.
|
4278
|
43 " manifest_parser.cc, ParseRule()
|
13589
|
44 syn region ninjaRule start="^rule" end="^\ze\S" contains=TOP transparent
|
|
45 syn keyword ninjaRuleCommand contained containedin=ninjaRule command
|
|
46 \ deps depfile description generator
|
4339
|
47 \ pool restat rspfile rspfile_content
|
4278
|
48
|
13589
|
49 syn region ninjaPool start="^pool" end="^\ze\S" contains=TOP transparent
|
|
50 syn keyword ninjaPoolCommand contained containedin=ninjaPool depth
|
3256
|
51
|
|
52 " Strings are parsed as follows:
|
|
53 " lexer.in.cc, ReadEvalString()
|
|
54 " simple_varname = [a-zA-Z0-9_-]+;
|
|
55 " varname = [a-zA-Z0-9_.-]+;
|
|
56 " $$ -> $
|
|
57 " $\n -> line continuation
|
|
58 " '$ ' -> escaped space
|
|
59 " $simple_varname -> variable
|
|
60 " ${varname} -> variable
|
|
61
|
5968
|
62 syn match ninjaDollar "\$\$"
|
3256
|
63 syn match ninjaWrapLineOperator "\$$"
|
|
64 syn match ninjaSimpleVar "\$[a-zA-Z0-9_-]\+"
|
|
65 syn match ninjaVar "\${[a-zA-Z0-9_.-]\+}"
|
|
66
|
|
67 " operators are:
|
|
68 " variable assignment =
|
|
69 " rule definition :
|
|
70 " implicit dependency |
|
|
71 " order-only dependency ||
|
|
72 syn match ninjaOperator "\(=\|:\||\|||\)\ze\s"
|
|
73
|
3513
|
74 hi def link ninjaComment Comment
|
3256
|
75 hi def link ninjaKeyword Keyword
|
|
76 hi def link ninjaRuleCommand Statement
|
4278
|
77 hi def link ninjaPoolCommand Statement
|
5968
|
78 hi def link ninjaDollar ninjaOperator
|
3256
|
79 hi def link ninjaWrapLineOperator ninjaOperator
|
|
80 hi def link ninjaOperator Operator
|
|
81 hi def link ninjaSimpleVar ninjaVar
|
|
82 hi def link ninjaVar Identifier
|
|
83
|
|
84 let b:current_syntax = "ninja"
|
4339
|
85
|
|
86 let &cpo = s:cpo_save
|
|
87 unlet s:cpo_save
|