Skip to content

Commit ed8a74e

Browse files
authored
Merge branch 'master' into master
2 parents eda42b8 + d0896ad commit ed8a74e

File tree

7 files changed

+828
-408
lines changed

7 files changed

+828
-408
lines changed

.github/workflows/vscode.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ jobs:
1313
name: Build
1414
runs-on: ${{ matrix.os }}
1515
strategy:
16+
fail-fast: false
1617
matrix:
1718
os: [macos-latest, ubuntu-latest, windows-latest]
1819
steps:
@@ -23,11 +24,11 @@ jobs:
2324
with:
2425
node-version: 20
2526

26-
- name: Set up Go 1.22
27+
- name: Set up Go
2728
uses: actions/setup-go@v5
2829
with:
2930
check-latest: true
30-
go-version: '1.22'
31+
go-version: '1.23'
3132

3233
- name: build
3334
run: |

language-configuration.json

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,25 @@
11
{
2-
"autoClosingPairs": [
3-
["<", ">"],
4-
["\"", "\""]
2+
"comments": {
3+
"lineComment": "//",
4+
},
5+
"autoClosingPairs": [
6+
[
7+
"<",
8+
">"
59
],
6-
"surroundingPairs": [
7-
["<", ">"],
8-
["\"", "\""]
10+
[
11+
"\"",
12+
"\""
913
]
14+
],
15+
"surroundingPairs": [
16+
[
17+
"<",
18+
">"
19+
],
20+
[
21+
"\"",
22+
"\""
23+
]
24+
]
1025
}

package-lock.json

Lines changed: 432 additions & 334 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 77 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"description": "Gauge support for VScode.",
99
"author": "ThoughtWorks",
1010
"license": "MIT",
11-
"version": "0.1.6",
11+
"version": "0.1.9",
1212
"publisher": "getgauge",
1313
"engines": {
1414
"vscode": "^1.71.0"
@@ -288,6 +288,71 @@
288288
"Ignore"
289289
],
290290
"description": "Gauge recommended settings are shown/ignored based on the given value."
291+
},
292+
"gauge.semanticTokenColors.argument": {
293+
"type": "string",
294+
"default": "#ae81ff",
295+
"description": "Color for arguments."
296+
},
297+
"gauge.semanticTokenColors.stepMarker": {
298+
"type": "string",
299+
"default": "#ffffff",
300+
"description": "Color for the step marker '*'"
301+
},
302+
"gauge.semanticTokenColors.step": {
303+
"type": "string",
304+
"default": "#a6e22e",
305+
"description": "Color for step text."
306+
},
307+
"gauge.semanticTokenColors.table": {
308+
"type": "string",
309+
"default": "#ae81ff",
310+
"description": "Color for table rows (cell data)."
311+
},
312+
"gauge.semanticTokenColors.tableHeaderSeparator": {
313+
"type": "string",
314+
"default": "#8349f0",
315+
"description": "Color for table separator dashes."
316+
},
317+
"gauge.semanticTokenColors.tableBorder": {
318+
"type": "string",
319+
"default": "#8349f0",
320+
"description": "Color for table table borders."
321+
},
322+
"gauge.semanticTokenColors.tagKeyword": {
323+
"type": "string",
324+
"default": "#ff4689",
325+
"description": "Color for tag keywords."
326+
},
327+
"gauge.semanticTokenColors.tagValue": {
328+
"type": "string",
329+
"default": "#fc88b2",
330+
"description": "Color for tag values."
331+
},
332+
"gauge.semanticTokenColors.specification": {
333+
"type": "string",
334+
"default": "#66d9ef",
335+
"description": "Color for specification/concept headers."
336+
},
337+
"gauge.semanticTokenColors.scenario": {
338+
"type": "string",
339+
"default": "#66d9ef",
340+
"description": "Color for scenario headers."
341+
},
342+
"gauge.semanticTokenColors.comment": {
343+
"type": "string",
344+
"default": "#cccccc",
345+
"description": "Color for comments."
346+
},
347+
"gauge.semanticTokenColors.disabledStep": {
348+
"type": "string",
349+
"default": "#228549",
350+
"description": "Color for disabled steps."
351+
},
352+
"gauge.formatting.skipEmptyLineInsertions": {
353+
"type": "boolean",
354+
"default": false,
355+
"description": "If true, skip adding empty lines during formatting."
291356
}
292357
}
293358
},
@@ -460,30 +525,30 @@
460525
},
461526
"devDependencies": {
462527
"@types/fs-extra": "^11.0.3",
463-
"@types/mocha": "^10.0.7",
464-
"@types/node": "^20.14.11",
528+
"@types/mocha": "^10.0.10",
529+
"@types/node": "^22.13.4",
465530
"@types/ps-tree": "^1.1.4",
466531
"@types/sinon": "^17.0.3",
467532
"@types/vscode": "~1.71.0",
468533
"@vscode/test-electron": "^2.4.1",
469534
"@vscode/vsce": "^2.31.1",
470535
"cross-env": "^7.0.3",
471-
"glob": "^11.0.0",
472-
"mocha": "^10.7.0",
473-
"sinon": "^18.0.0",
474-
"terser-webpack-plugin": "^5.3.10",
475-
"ts-loader": "^9.5.0",
536+
"glob": "^11.0.1",
537+
"mocha": "^11.1.0",
538+
"sinon": "^19.0.2",
539+
"terser-webpack-plugin": "^5.3.11",
540+
"ts-loader": "^9.5.2",
476541
"ts-mockito": "^2.6.1",
477542
"tslint": "^6.1.3",
478-
"typescript": "^5.5.4",
479-
"webpack": "^5.93.0",
543+
"typescript": "^5.7.3",
544+
"webpack": "^5.98.0",
480545
"webpack-cli": "^5.1.4"
481546
},
482547
"dependencies": {
483-
"fs-extra": "^11.2.0",
548+
"fs-extra": "^11.3.0",
484549
"get-port": "^5.1.1",
485550
"ps-tree": "^1.2.0",
486551
"vscode-languageclient": "~8.1.0",
487552
"xmlbuilder": "^15.1.1"
488553
}
489-
}
554+
}

src/extension.ts

Lines changed: 107 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,112 @@
1-
'use strict';
2-
3-
import { debug, ExtensionContext, languages, window, workspace } from 'vscode';
4-
import { GenerateStubCommandProvider } from './annotator/generateStub';
5-
import { CLI } from './cli';
6-
import { ConfigProvider } from './config/configProvider';
7-
import { ReferenceProvider } from './gaugeReference';
8-
import { GaugeState } from './gaugeState';
9-
import { GaugeWorkspace } from './gaugeWorkspace';
10-
import { ProjectInitializer } from './init/projectInit';
11-
import { ProjectFactory } from './project/projectFactory';
12-
import { hasActiveGaugeDocument } from './util';
13-
import { showInstallGaugeNotification, showWelcomeNotification } from './welcomeNotifications';
14-
import { GaugeClients as GaugeProjectClientMap } from './gaugeClients';
15-
16-
const MINIMUM_SUPPORTED_GAUGE_VERSION = '0.9.6';
17-
18-
const clientsMap: GaugeProjectClientMap = new GaugeProjectClientMap();
19-
20-
export async function activate(context: ExtensionContext) {
21-
let cli = CLI.instance();
22-
if (!cli) {
23-
return;
24-
}
25-
let folders = workspace.workspaceFolders;
26-
context.subscriptions.push(new ProjectInitializer(cli));
27-
let hasGaugeProject = folders && folders.some((f) => ProjectFactory.isGaugeProject(f.uri.fsPath));
28-
if (!hasActiveGaugeDocument(window.activeTextEditor) && !hasGaugeProject) return;
29-
if (!cli.isGaugeInstalled() || !cli.isGaugeVersionGreaterOrEqual(MINIMUM_SUPPORTED_GAUGE_VERSION)) {
30-
return showInstallGaugeNotification();
1+
'use strict';
2+
3+
import { debug, ExtensionContext, languages, window, workspace, ConfigurationTarget } from 'vscode';
4+
import { GenerateStubCommandProvider } from './annotator/generateStub';
5+
import { CLI } from './cli';
6+
import { ConfigProvider } from './config/configProvider';
7+
import { ReferenceProvider } from './gaugeReference';
8+
import { GaugeState } from './gaugeState';
9+
import { GaugeWorkspace } from './gaugeWorkspace';
10+
import { ProjectInitializer } from './init/projectInit';
11+
import { ProjectFactory } from './project/projectFactory';
12+
import { hasActiveGaugeDocument } from './util';
13+
import { showInstallGaugeNotification, showWelcomeNotification } from './welcomeNotifications';
14+
import { GaugeClients as GaugeProjectClientMap } from './gaugeClients';
15+
import { GaugeSemanticTokensProvider, legend } from './semanticTokensProvider';
16+
17+
const MINIMUM_SUPPORTED_GAUGE_VERSION = '0.9.6';
18+
19+
const clientsMap: GaugeProjectClientMap = new GaugeProjectClientMap();
20+
21+
// This function reads Gauge-specific semantic token colors from the configuration
22+
// and then updates the editor.semanticTokenColorCustomizations setting.
23+
function updateGaugeSemanticTokenColors() {
24+
// Read Gauge settings from the gauge configuration section.
25+
const gaugeConfig = workspace.getConfiguration("gauge.semanticTokenColors");
26+
const colors = {
27+
argument: gaugeConfig.get("argument"),
28+
stepMarker: gaugeConfig.get("stepMarker"),
29+
step: gaugeConfig.get("step"),
30+
table: gaugeConfig.get("table"),
31+
tableHeaderSeparator: gaugeConfig.get("tableHeaderSeparator"),
32+
tableBorder: gaugeConfig.get("tableBorder"),
33+
tagKeyword: gaugeConfig.get("tagKeyword"),
34+
tagValue: gaugeConfig.get("tagValue"),
35+
specification: gaugeConfig.get("specification"),
36+
scenario: gaugeConfig.get("scenario"),
37+
comment: gaugeConfig.get("comment"),
38+
disabledStep: gaugeConfig.get("disabledStep")
39+
};
40+
41+
// Build a new set of semantic token color rules.
42+
const semanticTokenRules = {
43+
"argument": { "foreground": colors.argument },
44+
"stepMarker": { "foreground": colors.stepMarker },
45+
"step": { "foreground": colors.step },
46+
"table": { "foreground": colors.table },
47+
"tableHeaderSeparator": { "foreground": colors.tableHeaderSeparator },
48+
"tableBorder": { "foreground": colors.tableBorder },
49+
"tagKeyword": { "foreground": colors.tagKeyword },
50+
"tagValue": { "foreground": colors.tagValue },
51+
"specification": { "foreground": colors.specification },
52+
"scenario": { "foreground": colors.scenario },
53+
"gaugeComment": { "foreground": colors.comment },
54+
"disabledStep": { "foreground": colors.disabledStep }
55+
};
56+
57+
// Get the current global editor configuration.
58+
const editorConfig = workspace.getConfiguration("editor");
59+
60+
// Update the semantic token color customizations.
61+
editorConfig.update("semanticTokenColorCustomizations", { rules: semanticTokenRules }, ConfigurationTarget.Global);
3162
}
32-
showWelcomeNotification(context);
33-
languages.setLanguageConfiguration('gauge', { wordPattern: /^(?:[*])([^*].*)$/g });
34-
let gaugeWorkspace = new GaugeWorkspace(new GaugeState(context), cli, clientsMap);
35-
36-
context.subscriptions.push(
37-
gaugeWorkspace,
38-
new ReferenceProvider(clientsMap),
39-
new GenerateStubCommandProvider(clientsMap),
40-
new ConfigProvider(context),
41-
debug.registerDebugConfigurationProvider('gauge',
42-
{
43-
resolveDebugConfiguration: () => {
44-
throw Error("Starting with the Gauge debug configuration is not supported. Please use the 'Gauge' commands instead.");
63+
64+
export async function activate(context: ExtensionContext) {
65+
let cli = CLI.instance();
66+
if (!cli) {
67+
return;
68+
}
69+
let folders = workspace.workspaceFolders;
70+
context.subscriptions.push(new ProjectInitializer(cli));
71+
let hasGaugeProject = folders && folders.some((f) => ProjectFactory.isGaugeProject(f.uri.fsPath));
72+
if (!hasActiveGaugeDocument(window.activeTextEditor) && !hasGaugeProject) return;
73+
if (!cli.isGaugeInstalled() || !cli.isGaugeVersionGreaterOrEqual(MINIMUM_SUPPORTED_GAUGE_VERSION)) {
74+
return showInstallGaugeNotification();
75+
}
76+
showWelcomeNotification(context);
77+
languages.setLanguageConfiguration('gauge', { wordPattern: /^(?:[*])([^*].*)$/g });
78+
let gaugeWorkspace = new GaugeWorkspace(new GaugeState(context), cli, clientsMap);
79+
updateGaugeSemanticTokenColors();
80+
81+
context.subscriptions.push(
82+
gaugeWorkspace,
83+
new ReferenceProvider(clientsMap),
84+
new GenerateStubCommandProvider(clientsMap),
85+
new ConfigProvider(context),
86+
debug.registerDebugConfigurationProvider('gauge',
87+
{
88+
resolveDebugConfiguration: () => {
89+
throw Error("Starting with the Gauge debug configuration is not supported. Please use the 'Gauge' commands instead.");
90+
}
91+
}),
92+
languages.registerDocumentSemanticTokensProvider(
93+
{ language: 'gauge' },
94+
new GaugeSemanticTokensProvider(),
95+
legend
96+
),
97+
workspace.onDidChangeConfiguration((e) => {
98+
if (e.affectsConfiguration("gauge.semanticTokenColors")) {
99+
updateGaugeSemanticTokenColors();
45100
}
46101
})
47-
);
48-
}
102+
);
103+
}
49104

50-
export function deactivate(): Thenable<void> {
51-
const promises: Thenable<void>[] = [];
105+
export function deactivate(): Thenable<void> {
106+
const promises: Thenable<void>[] = [];
52107

53-
for (const {client} of clientsMap.values()) {
54-
promises.push(client.stop());
55-
}
56-
return Promise.all(promises).then(() => undefined);
57-
}
108+
for (const { client } of clientsMap.values()) {
109+
promises.push(client.stop());
110+
}
111+
return Promise.all(promises).then(() => undefined);
112+
}

src/gaugeWorkspace.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,9 @@ export class GaugeWorkspace extends Disposable {
170170
diagnosticCollectionName: 'gauge',
171171
outputChannel: this._outputChannel,
172172
revealOutputChannelOn: RevealOutputChannelOn.Never,
173+
synchronize: {
174+
configurationSection: 'gauge'
175+
},
173176
};
174177
clientOptions.workspaceFolder = workspace.getWorkspaceFolder(Uri.file(folder));
175178
let languageClient = new LanguageClient('gauge', 'Gauge', serverOptions, clientOptions);
@@ -233,6 +236,4 @@ export class GaugeWorkspace extends Disposable {
233236
}
234237
});
235238
}
236-
237-
238239
}

0 commit comments

Comments
 (0)