Skip to content

Commit f7372e6

Browse files
author
James Pogran
authored
Merge pull request #458 from glennsarti/add-puppetfile-language
(GH-295)(GH-288) Add puppetfile support
2 parents f88697f + ca6a96a commit f7372e6

File tree

7 files changed

+2855
-7
lines changed

7 files changed

+2855
-7
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"comments": {
3+
// symbol used for single line comment. Remove this entry if your language does not support line comments
4+
"lineComment": "#",
5+
// symbols used for start and end a block comment. Remove this entry if your language does not support block comments
6+
"blockComment": ["/*","*/"]
7+
},
8+
// symbols used as brackets
9+
"brackets": [
10+
["{", "}"],
11+
["[", "]"],
12+
["(", ")"]
13+
],
14+
// symbols that are auto closed when typing
15+
"autoClosingPairs": [
16+
["{", "}"],
17+
["[", "]"],
18+
["(", ")"],
19+
["\"", "\""],
20+
["'", "'"]
21+
],
22+
// symbols that that can be used to surround a selection
23+
"surroundingPairs": [
24+
["{", "}"],
25+
["[", "]"],
26+
["(", ")"],
27+
["\"", "\""],
28+
["'", "'"]
29+
],
30+
// support for region folding
31+
"folding": {
32+
"offSide": true,
33+
"markers": {
34+
"start": "^\\s*#\\s*region\\b",
35+
"end": "^\\s*#\\s*endregion\\b"
36+
}
37+
}
38+
}

package.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
],
4040
"activationEvents": [
4141
"onLanguage:puppet",
42+
"onLanguage:puppetfile",
4243
"onCommand:extension.puppetShowConnectionLogs",
4344
"onCommand:extension.puppetShowConnectionMenu",
4445
"onCommand:extension.puppetLint",
@@ -65,6 +66,17 @@
6566
".epp"
6667
],
6768
"configuration": "./languages/puppet-language-configuration.json"
69+
},
70+
{
71+
"id": "puppetfile",
72+
"aliases": [
73+
"Puppetfile",
74+
"PuppetFile"
75+
],
76+
"filenames": [
77+
"Puppetfile"
78+
],
79+
"configuration": "./languages/puppetfile-language-configuration.json"
6880
}
6981
],
7082
"jsonValidation": [
@@ -82,6 +94,11 @@
8294
"language": "puppet",
8395
"scopeName": "source.puppet",
8496
"path": "./syntaxes/puppet.tmLanguage"
97+
},
98+
{
99+
"language": "puppetfile",
100+
"scopeName": "source.ruby",
101+
"path": "./syntaxes/puppetfile.cson.json"
85102
}
86103
],
87104
"snippets": [
@@ -92,6 +109,10 @@
92109
{
93110
"language": "json",
94111
"path": "./snippets/metadata.snippets.json"
112+
},
113+
{
114+
"language": "puppetfile",
115+
"path": "./snippets/puppetfile.snippets.json"
95116
}
96117
],
97118
"commands": [

snippets/puppetfile.snippets.json

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
{
2+
"Forge_module1": {
3+
"prefix": "Forge Module",
4+
"body": ["mod '${1:author}-${2:name}', '${3:version}'"],
5+
"description": "Install from the forge"
6+
},
7+
"Forge_module2": {
8+
"prefix": "Latest Forge Module",
9+
"body": ["mod '${1:author}-${2:name}', :latest"],
10+
"description": "Install the latest version from the forge"
11+
},
12+
"Git_module1": {
13+
"prefix": "Git Module by ref",
14+
"body": [
15+
"mod '${1:name}',",
16+
"\t:git => '${2:repository}',",
17+
"\t:ref => '${3:reference}'"
18+
],
19+
"description": "Install from a git repository specified by a git reference e.g. master"
20+
},
21+
"Git_module2": {
22+
"prefix": "Git Module by commit",
23+
"body": [
24+
"mod '${1:name}',",
25+
"\t:git => '${2:repository}',",
26+
"\t:commit => '${3:commit}'"
27+
],
28+
"description": "Install from a git repository specified by a git commit e.g. 1c40e29"
29+
},
30+
"Git_module3": {
31+
"prefix": "Git Module by tag",
32+
"body": [
33+
"mod '${1:name}',",
34+
"\t:git => '${2:repository}',",
35+
"\t:tag => '${3:tag}'"
36+
],
37+
"description": "Install from a git repository specified by a git tag e.g. v1.0.0"
38+
},
39+
"Git_module4": {
40+
"prefix": "Git Module by branch",
41+
"body": [
42+
"mod '${1:name}',",
43+
"\t:git => '${2:repository}',",
44+
"\t:branch => '${3:branch}'"
45+
],
46+
"description": "Install from a git repository specified by a git branch e.g. release"
47+
},
48+
"Svn_module1": {
49+
"prefix": "Svn Module by revision",
50+
"body": [
51+
"mod '${1:name}',",
52+
"\t:svn => '${2:repository}',",
53+
"\t:revision => '${3:revision}'"
54+
],
55+
"description": "Install from a SVN repository specified by a revision e.g. 154"
56+
},
57+
"Local_module1": {
58+
"prefix": "Local Module",
59+
"body": ["mod '${1:name}', :local => true"],
60+
"description": "Install from the local Puppetfile module path"
61+
}
62+
}

src/PuppetStatusBar.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export class PuppetStatusBar {
88
statusBarItem: vscode.StatusBarItem;
99
private logger: ILogger;
1010

11-
constructor(langID: string, context:vscode.ExtensionContext, logger: ILogger) {
11+
constructor(langIDs: string[], context:vscode.ExtensionContext, logger: ILogger) {
1212
this.logger = logger;
1313
context.subscriptions.push(vscode.commands.registerCommand(PuppetCommandStrings.PuppetShowConnectionMenuCommandId,
1414
() => { PuppetStatusBar.showConnectionMenu(); }
@@ -17,7 +17,7 @@ export class PuppetStatusBar {
1717
this.statusBarItem.command = PuppetCommandStrings.PuppetShowConnectionMenuCommandId;
1818
this.statusBarItem.show();
1919
vscode.window.onDidChangeActiveTextEditor(textEditor => {
20-
if (textEditor === undefined || textEditor.document.languageId !== langID) {
20+
if (textEditor === undefined || langIDs.indexOf(textEditor.document.languageId) === -1) {
2121
this.statusBarItem.hide();
2222
} else {
2323
this.statusBarItem.show();

src/extension.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ import { PuppetStatusBar } from './PuppetStatusBar';
2121
import { ISettings, legacySettings, settingsFromWorkspace } from './settings';
2222
import { Reporter, reporter } from './telemetry/telemetry';
2323

24-
const langID = 'puppet'; // don't change this
24+
export const puppetLangID = 'puppet'; // don't change this
25+
export const puppetFileLangID = 'puppetfile'; // don't change this
26+
2527
let extContext: vscode.ExtensionContext;
2628
let connectionHandler: ConnectionHandler;
2729
let settings: ISettings;
@@ -40,7 +42,7 @@ export function activate(context: vscode.ExtensionContext) {
4042

4143
settings = settingsFromWorkspace();
4244
logger = new OutputChannelLogger(settings);
43-
statusBar = new PuppetStatusBar(langID, context, logger);
45+
statusBar = new PuppetStatusBar([puppetLangID, puppetFileLangID], context, logger);
4446
configSettings = new ConnectionConfiguration();
4547

4648
if(settings.editorService.enable === false){
@@ -68,8 +70,8 @@ export function activate(context: vscode.ExtensionContext) {
6870

6971
extensionFeatures = [
7072
new DebugConfigurationFeature(logger, extContext),
71-
new FormatDocumentFeature(langID, connectionHandler, settings, logger, extContext),
72-
new NodeGraphFeature(langID, connectionHandler, logger, extContext),
73+
new FormatDocumentFeature(puppetLangID, connectionHandler, settings, logger, extContext),
74+
new NodeGraphFeature(puppetLangID, connectionHandler, logger, extContext),
7375
new PDKFeature(extContext, logger),
7476
new PuppetResourceFeature(extContext, connectionHandler, logger)
7577
];

src/handler.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { OutputChannelLogger } from './logging/outputchannel';
77
import { ISettings } from './settings';
88
import { PuppetVersionDetails, PuppetVersionRequest, PuppetCommandStrings } from './messages';
99
import { reporter } from './telemetry/telemetry';
10+
import { puppetFileLangID, puppetLangID} from './extension';
1011

1112
export abstract class ConnectionHandler {
1213
private timeSpent:number;
@@ -37,7 +38,7 @@ export abstract class ConnectionHandler {
3738
this.timeSpent = Date.now();
3839
this.setConnectionStatus('Initializing', ConnectionStatus.Initializing);
3940

40-
let documents = [{ scheme: 'file', language: 'puppet' }];
41+
let documents = [{ scheme: 'file', language: puppetLangID }, { scheme: 'file', language: puppetFileLangID }];
4142

4243
this.logger.debug('Configuring language client options');
4344
let clientOptions: LanguageClientOptions = {

0 commit comments

Comments
 (0)