Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Fixes resources with variable name #29

Merged
merged 1 commit into from
Mar 12, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions grammars/puppet.cson
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,15 @@
'match': '^\\s*(\\w+)\\s*{\\s*([\'"].+[\'"]):'
'name': 'meta.definition.resource.puppet'
}
{
'match': '^\\s*(\\w+)\\s*{\\s*(\\$[a-zA-Z_]+)\\s*:'
'captures':
'1':
'name': 'storage.type.puppet'
'2':
'name': 'entity.name.section.puppet'
'name': 'meta.definition.resource.puppet'
}
{
'match': '\\b(case|if|else|elsif)(?!::)\\b'
'name': 'keyword.control.puppet'
Expand Down
10 changes: 10 additions & 0 deletions spec/puppet-spec.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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']