From bff884d550cdd4479b3a9aea29ebb0e9ff106e80 Mon Sep 17 00:00:00 2001 From: Mathias Stearn Date: Thu, 9 Nov 2017 12:00:04 -0500 Subject: Improve vim syntax definition Only highlights comments where the ninja lexer would treat them as such. Also correctly scopes the rule- and pool-specific variables highlighting. --- misc/ninja.vim | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/misc/ninja.vim b/misc/ninja.vim index 190d9ce..6912d0d 100644 --- a/misc/ninja.vim +++ b/misc/ninja.vim @@ -21,7 +21,10 @@ set cpo&vim syn case match -syn match ninjaComment /#.*/ contains=@Spell +" Comments are only matched when the # is at the beginning of the line (with +" optional whitespace), as long as the prior line didn't end with a $ +" continuation. +syn match ninjaComment /\(\$\n\)\@" " limited set of magic variables, 'build' allows general " let assignments. " manifest_parser.cc, ParseRule() -syn region ninjaRule start="^rule" end="^\ze\S" contains=ALL transparent -syn keyword ninjaRuleCommand contained command deps depfile description generator +syn region ninjaRule start="^rule" end="^\ze\S" contains=TOP transparent +syn keyword ninjaRuleCommand contained containedin=ninjaRule command + \ deps depfile description generator \ pool restat rspfile rspfile_content -syn region ninjaPool start="^pool" end="^\ze\S" contains=ALL transparent -syn keyword ninjaPoolCommand contained depth +syn region ninjaPool start="^pool" end="^\ze\S" contains=TOP transparent +syn keyword ninjaPoolCommand contained containedin=ninjaPool depth " Strings are parsed as follows: " lexer.in.cc, ReadEvalString() -- cgit v0.12