diff --git a/grammars/puppet.cson b/grammars/puppet.cson index d2a2f0e..82d3b68 100644 --- a/grammars/puppet.cson +++ b/grammars/puppet.cson @@ -122,6 +122,15 @@ 'match': '^\\s*(\\w+)\\s*{\\s*([\'"].+[\'"]):' 'name': 'meta.definition.resource.puppet' } + { + 'captures': + '1': + 'name': 'storage.type.puppet' + '2': + 'name': 'entity.name.section.puppet' + 'match': '^\\s*(\\w+)\\s*{\\s*(\\$[a-zA-Z_]+)\\s*:' + 'name': 'meta.definition.resource.puppet' + } { 'match': '\\b(case|if|else|elsif)(?!::)\\b' 'name': 'keyword.control.puppet' diff --git a/spec/puppet-spec.coffee b/spec/puppet-spec.coffee index 57cb1c1..893600d 100644 --- a/spec/puppet-spec.coffee +++ b/spec/puppet-spec.coffee @@ -37,3 +37,13 @@ describe "Puppet grammar", -> it "tokenizes contain as an include function", -> {tokens} = grammar.tokenizeLine('include foo') expect(tokens[0]).toEqual value: 'include', scopes: ['source.puppet', 'meta.include.puppet', 'keyword.control.import.include.puppet'] + + it "tokenizes resource type and string title", -> + {tokens} = grammar.tokenizeLine("package {'foo':}") + expect(tokens[0]).toEqual value: 'package', scopes: ['source.puppet', 'meta.definition.resource.puppet', 'storage.type.puppet'] + expect(tokens[2]).toEqual value: "'foo'", scopes: ['source.puppet', 'meta.definition.resource.puppet', 'entity.name.section.puppet'] + + it "tokenizes resource type and variable title", -> + {tokens} = grammar.tokenizeLine("package {$foo:}") + expect(tokens[0]).toEqual value: 'package', scopes: ['source.puppet', 'meta.definition.resource.puppet', 'storage.type.puppet'] + expect(tokens[2]).toEqual value: '$foo', scopes: ['source.puppet', 'meta.definition.resource.puppet', 'entity.name.section.puppet']