Skip to content
This repository was archived by the owner on Jun 15, 2023. It is now read-only.

Commit bff884d

Browse files
committed
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.
1 parent e234a7b commit bff884d

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

misc/ninja.vim

+9-5
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ set cpo&vim
2121

2222
syn case match
2323

24-
syn match ninjaComment /#.*/ contains=@Spell
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
2528

2629
" Toplevel statements are the ones listed here and
2730
" toplevel variable assignments (ident '=' value).
@@ -38,12 +41,13 @@ syn match ninjaKeyword "^subninja\>"
3841
" limited set of magic variables, 'build' allows general
3942
" let assignments.
4043
" 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
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
4347
\ pool restat rspfile rspfile_content
4448

45-
syn region ninjaPool start="^pool" end="^\ze\S" contains=ALL transparent
46-
syn keyword ninjaPoolCommand contained depth
49+
syn region ninjaPool start="^pool" end="^\ze\S" contains=TOP transparent
50+
syn keyword ninjaPoolCommand contained containedin=ninjaPool depth
4751

4852
" Strings are parsed as follows:
4953
" lexer.in.cc, ReadEvalString()

0 commit comments

Comments
 (0)