blob: f34588f60c3e1eaa8e76745a35e50e06c6c11849 [file] [log] [blame]
Bram Moolenaar6ee8d892012-01-10 14:55:01 +01001" ninja build file syntax.
2" Language: ninja build file as described at
3" http://martine.github.com/ninja/manual.html
Bram Moolenaar822ff862014-06-12 21:46:14 +02004" Version: 1.4
5" Last Change: 2014/05/13
Bram Moolenaar6ee8d892012-01-10 14:55:01 +01006" Maintainer: Nicolas Weber <nicolasweber@gmx.de>
Bram Moolenaar822ff862014-06-12 21:46:14 +02007" Version 1.4 of this script is in the upstream vim repository and will be
Bram Moolenaarff034192013-04-24 18:51:19 +02008" included in the next vim release. If you change this, please send your change
9" upstream.
Bram Moolenaar6ee8d892012-01-10 14:55:01 +010010
11" ninja lexer and parser are at
12" https://github.com/martine/ninja/blob/master/src/lexer.in.cc
Bram Moolenaar0187ca02013-04-12 15:09:51 +020013" https://github.com/martine/ninja/blob/master/src/manifest_parser.cc
Bram Moolenaar6ee8d892012-01-10 14:55:01 +010014
15if exists("b:current_syntax")
16 finish
17endif
18
Bram Moolenaarff034192013-04-24 18:51:19 +020019let s:cpo_save = &cpo
20set cpo&vim
21
Bram Moolenaar6ee8d892012-01-10 14:55:01 +010022syn case match
23
Bram Moolenaar30b65812012-07-12 22:01:11 +020024syn match ninjaComment /#.*/ contains=@Spell
Bram Moolenaar1aeaf8c2012-05-18 13:46:39 +020025
Bram Moolenaar6ee8d892012-01-10 14:55:01 +010026" Toplevel statements are the ones listed here and
27" toplevel variable assignments (ident '=' value).
Bram Moolenaar0187ca02013-04-12 15:09:51 +020028" lexer.in.cc, ReadToken() and manifest_parser.cc, Parse()
Bram Moolenaar6ee8d892012-01-10 14:55:01 +010029syn match ninjaKeyword "^build\>"
30syn match ninjaKeyword "^rule\>"
Bram Moolenaar0187ca02013-04-12 15:09:51 +020031syn match ninjaKeyword "^pool\>"
Bram Moolenaar6ee8d892012-01-10 14:55:01 +010032syn match ninjaKeyword "^default\>"
33syn match ninjaKeyword "^include\>"
34syn match ninjaKeyword "^subninja\>"
35
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
39" let assignments.
Bram Moolenaar0187ca02013-04-12 15:09:51 +020040" manifest_parser.cc, ParseRule()
Bram Moolenaar6ee8d892012-01-10 14:55:01 +010041syn region ninjaRule start="^rule" end="^\ze\S" contains=ALL transparent
Bram Moolenaarff034192013-04-24 18:51:19 +020042syn keyword ninjaRuleCommand contained command deps depfile description generator
43 \ pool restat rspfile rspfile_content
Bram Moolenaar0187ca02013-04-12 15:09:51 +020044
45syn region ninjaPool start="^pool" end="^\ze\S" contains=ALL transparent
46syn keyword ninjaPoolCommand contained depth
Bram Moolenaar6ee8d892012-01-10 14:55:01 +010047
48" Strings are parsed as follows:
49" lexer.in.cc, ReadEvalString()
50" simple_varname = [a-zA-Z0-9_-]+;
51" varname = [a-zA-Z0-9_.-]+;
52" $$ -> $
53" $\n -> line continuation
54" '$ ' -> escaped space
55" $simple_varname -> variable
56" ${varname} -> variable
57
Bram Moolenaar822ff862014-06-12 21:46:14 +020058syn match ninjaDollar "\$\$"
Bram Moolenaar6ee8d892012-01-10 14:55:01 +010059syn match ninjaWrapLineOperator "\$$"
60syn match ninjaSimpleVar "\$[a-zA-Z0-9_-]\+"
61syn match ninjaVar "\${[a-zA-Z0-9_.-]\+}"
62
63" operators are:
64" variable assignment =
65" rule definition :
66" implicit dependency |
67" order-only dependency ||
68syn match ninjaOperator "\(=\|:\||\|||\)\ze\s"
69
Bram Moolenaar1aeaf8c2012-05-18 13:46:39 +020070hi def link ninjaComment Comment
Bram Moolenaar6ee8d892012-01-10 14:55:01 +010071hi def link ninjaKeyword Keyword
72hi def link ninjaRuleCommand Statement
Bram Moolenaar0187ca02013-04-12 15:09:51 +020073hi def link ninjaPoolCommand Statement
Bram Moolenaar822ff862014-06-12 21:46:14 +020074hi def link ninjaDollar ninjaOperator
Bram Moolenaar6ee8d892012-01-10 14:55:01 +010075hi def link ninjaWrapLineOperator ninjaOperator
76hi def link ninjaOperator Operator
77hi def link ninjaSimpleVar ninjaVar
78hi def link ninjaVar Identifier
79
80let b:current_syntax = "ninja"
Bram Moolenaarff034192013-04-24 18:51:19 +020081
82let &cpo = s:cpo_save
83unlet s:cpo_save