summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNico Weber <thakis@chromium.org>2012-01-04 21:52:11 (GMT)
committerNico Weber <thakis@chromium.org>2012-01-04 21:52:11 (GMT)
commit98956ab4e88dcebfdef0fe4f6e44adfde6103d1b (patch)
treec9da0751c849394df07b8875802e0b6b69df3b87
parentb12139c13e8924ce4d0e634f5798274a5d87f5d7 (diff)
downloadNinja-98956ab4e88dcebfdef0fe4f6e44adfde6103d1b.zip
Ninja-98956ab4e88dcebfdef0fe4f6e44adfde6103d1b.tar.gz
Ninja-98956ab4e88dcebfdef0fe4f6e44adfde6103d1b.tar.bz2
Add a ninja syntax file for vim.
-rw-r--r--misc/ninja.vim66
1 files changed, 66 insertions, 0 deletions
diff --git a/misc/ninja.vim b/misc/ninja.vim
new file mode 100644
index 0000000..24fc9b4
--- /dev/null
+++ b/misc/ninja.vim
@@ -0,0 +1,66 @@
+" ninja build file syntax.
+" Language: ninja build file as described at
+" http://martine.github.com/ninja/manual.html
+" Version: 1.0
+" Last Change: 2011/12/31
+" Maintainer: Nicolas Weber <nicolasweber@gmx.de>
+" Version 1.0 of this script is in the upstream vim repository and will be
+" included in the next vim release. If you change this, please send your change
+" upstream.
+
+" ninja lexer and parser are at
+" https://github.com/martine/ninja/blob/master/src/lexer.in.cc
+" https://github.com/martine/ninja/blob/master/src/parsers.cc
+
+if exists("b:current_syntax")
+ finish
+endif
+
+syn case match
+
+" Toplevel statements are the ones listed here and
+" toplevel variable assignments (ident '=' value).
+" lexer.in.cc, ReadToken() and parsers.cc, Parse()
+syn match ninjaKeyword "^build\>"
+syn match ninjaKeyword "^rule\>"
+syn match ninjaKeyword "^default\>"
+syn match ninjaKeyword "^include\>"
+syn match ninjaKeyword "^subninja\>"
+
+" Both 'build' and 'rule' begin a variable scope that ends
+" on the first line without indent. 'rule' allows only a
+" limited set of magic variables, 'build' allows general
+" let assignments.
+" parsers.cc, ParseRule()
+syn region ninjaRule start="^rule" end="^\ze\S" contains=ALL transparent
+syn keyword ninjaRuleCommand contained command depfile description generator restat
+
+" Strings are parsed as follows:
+" lexer.in.cc, ReadEvalString()
+" simple_varname = [a-zA-Z0-9_-]+;
+" varname = [a-zA-Z0-9_.-]+;
+" $$ -> $
+" $\n -> line continuation
+" '$ ' -> escaped space
+" $simple_varname -> variable
+" ${varname} -> variable
+
+syn match ninjaWrapLineOperator "\$$"
+syn match ninjaSimpleVar "\$[a-zA-Z0-9_-]\+"
+syn match ninjaVar "\${[a-zA-Z0-9_.-]\+}"
+
+" operators are:
+" variable assignment =
+" rule definition :
+" implicit dependency |
+" order-only dependency ||
+syn match ninjaOperator "\(=\|:\||\|||\)\ze\s"
+
+hi def link ninjaKeyword Keyword
+hi def link ninjaRuleCommand Statement
+hi def link ninjaWrapLineOperator ninjaOperator
+hi def link ninjaOperator Operator
+hi def link ninjaSimpleVar ninjaVar
+hi def link ninjaVar Identifier
+
+let b:current_syntax = "ninja"