Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added setting for config Gauge formatter and send the settings to Gauge server. #1038

27 changes: 21 additions & 6 deletions language-configuration.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,25 @@
{
"autoClosingPairs": [
["<", ">"],
["\"", "\""]
"comments": {
"lineComment": "//",
},
"autoClosingPairs": [
[
"<",
">"
],
"surroundingPairs": [
["<", ">"],
["\"", "\""]
[
"\"",
"\""
]
],
"surroundingPairs": [
[
"<",
">"
],
[
"\"",
"\""
]
]
}
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

71 changes: 68 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"description": "Gauge support for VScode.",
"author": "ThoughtWorks",
"license": "MIT",
"version": "0.1.6",
"version": "0.1.8",
"publisher": "getgauge",
"engines": {
"vscode": "^1.71.0"
Expand Down Expand Up @@ -288,6 +288,71 @@
"Ignore"
],
"description": "Gauge recommended settings are shown/ignored based on the given value."
},
"gauge.semanticTokenColors.argument": {
"type": "string",
"default": "#ae81ff",
"description": "Color for arguments."
},
"gauge.semanticTokenColors.stepMarker": {
"type": "string",
"default": "#ffffff",
"description": "Color for the step marker '*'"
},
"gauge.semanticTokenColors.step": {
"type": "string",
"default": "#a6e22e",
"description": "Color for step text."
},
"gauge.semanticTokenColors.table": {
"type": "string",
"default": "#ae81ff",
"description": "Color for table rows (cell data)."
},
"gauge.semanticTokenColors.tableHeaderSeparator": {
"type": "string",
"default": "#8349f0",
"description": "Color for table separator dashes."
},
"gauge.semanticTokenColors.tableBorder": {
"type": "string",
"default": "#8349f0",
"description": "Color for table table borders."
},
"gauge.semanticTokenColors.tagKeyword": {
"type": "string",
"default": "#ff4689",
"description": "Color for tag keywords."
},
"gauge.semanticTokenColors.tagValue": {
"type": "string",
"default": "#fc88b2",
"description": "Color for tag values."
},
"gauge.semanticTokenColors.specification": {
"type": "string",
"default": "#66d9ef",
"description": "Color for specification/concept headers."
},
"gauge.semanticTokenColors.scenario": {
"type": "string",
"default": "#66d9ef",
"description": "Color for scenario headers."
},
"gauge.semanticTokenColors.comment": {
"type": "string",
"default": "#cccccc",
"description": "Color for comments."
},
"gauge.semanticTokenColors.disabledStep": {
"type": "string",
"default": "#228549",
"description": "Color for disabled steps."
},
"gauge.formatting.skipEmptyLineInsertions": {
"type": "boolean",
"default": false,
"description": "If true, skip adding empty lines during formatting."
}
}
},
Expand Down Expand Up @@ -461,7 +526,7 @@
"devDependencies": {
"@types/fs-extra": "^11.0.3",
"@types/mocha": "^10.0.10",
"@types/node": "^22.10.10",
"@types/node": "^22.13.0",
"@types/ps-tree": "^1.1.4",
"@types/sinon": "^17.0.3",
"@types/vscode": "~1.71.0",
Expand All @@ -486,4 +551,4 @@
"vscode-languageclient": "~8.1.0",
"xmlbuilder": "^15.1.1"
}
}
}
159 changes: 107 additions & 52 deletions src/extension.ts
Original file line number Diff line number Diff line change
@@ -1,57 +1,112 @@
'use strict';

import { debug, ExtensionContext, languages, window, workspace } from 'vscode';
import { GenerateStubCommandProvider } from './annotator/generateStub';
import { CLI } from './cli';
import { ConfigProvider } from './config/configProvider';
import { ReferenceProvider } from './gaugeReference';
import { GaugeState } from './gaugeState';
import { GaugeWorkspace } from './gaugeWorkspace';
import { ProjectInitializer } from './init/projectInit';
import { ProjectFactory } from './project/projectFactory';
import { hasActiveGaugeDocument } from './util';
import { showInstallGaugeNotification, showWelcomeNotification } from './welcomeNotifications';
import { GaugeClients as GaugeProjectClientMap } from './gaugeClients';

const MINIMUM_SUPPORTED_GAUGE_VERSION = '0.9.6';

const clientsMap: GaugeProjectClientMap = new GaugeProjectClientMap();

export async function activate(context: ExtensionContext) {
let cli = CLI.instance();
if (!cli) {
return;
}
let folders = workspace.workspaceFolders;
context.subscriptions.push(new ProjectInitializer(cli));
let hasGaugeProject = folders && folders.some((f) => ProjectFactory.isGaugeProject(f.uri.fsPath));
if (!hasActiveGaugeDocument(window.activeTextEditor) && !hasGaugeProject) return;
if (!cli.isGaugeInstalled() || !cli.isGaugeVersionGreaterOrEqual(MINIMUM_SUPPORTED_GAUGE_VERSION)) {
return showInstallGaugeNotification();
'use strict';

import { debug, ExtensionContext, languages, window, workspace, ConfigurationTarget } from 'vscode';
import { GenerateStubCommandProvider } from './annotator/generateStub';
import { CLI } from './cli';
import { ConfigProvider } from './config/configProvider';
import { ReferenceProvider } from './gaugeReference';
import { GaugeState } from './gaugeState';
import { GaugeWorkspace } from './gaugeWorkspace';
import { ProjectInitializer } from './init/projectInit';
import { ProjectFactory } from './project/projectFactory';
import { hasActiveGaugeDocument } from './util';
import { showInstallGaugeNotification, showWelcomeNotification } from './welcomeNotifications';
import { GaugeClients as GaugeProjectClientMap } from './gaugeClients';
import { GaugeSemanticTokensProvider, legend } from './semanticTokensProvider';

const MINIMUM_SUPPORTED_GAUGE_VERSION = '0.9.6';

const clientsMap: GaugeProjectClientMap = new GaugeProjectClientMap();

// This function reads Gauge-specific semantic token colors from the configuration
// and then updates the editor.semanticTokenColorCustomizations setting.
function updateGaugeSemanticTokenColors() {
// Read Gauge settings from the gauge configuration section.
const gaugeConfig = workspace.getConfiguration("gauge.semanticTokenColors");
const colors = {
argument: gaugeConfig.get("argument"),
stepMarker: gaugeConfig.get("stepMarker"),
step: gaugeConfig.get("step"),
table: gaugeConfig.get("table"),
tableHeaderSeparator: gaugeConfig.get("tableHeaderSeparator"),
tableBorder: gaugeConfig.get("tableBorder"),
tagKeyword: gaugeConfig.get("tagKeyword"),
tagValue: gaugeConfig.get("tagValue"),
specification: gaugeConfig.get("specification"),
scenario: gaugeConfig.get("scenario"),
comment: gaugeConfig.get("comment"),
disabledStep: gaugeConfig.get("disabledStep")
};

// Build a new set of semantic token color rules.
const semanticTokenRules = {
"argument": { "foreground": colors.argument },
"stepMarker": { "foreground": colors.stepMarker },
"step": { "foreground": colors.step },
"table": { "foreground": colors.table },
"tableHeaderSeparator": { "foreground": colors.tableHeaderSeparator },
"tableBorder": { "foreground": colors.tableBorder },
"tagKeyword": { "foreground": colors.tagKeyword },
"tagValue": { "foreground": colors.tagValue },
"specification": { "foreground": colors.specification },
"scenario": { "foreground": colors.scenario },
"comment": { "foreground": colors.comment },
"disabledStep": { "foreground": colors.disabledStep }
};

// Get the current global editor configuration.
const editorConfig = workspace.getConfiguration("editor");

// Update the semantic token color customizations.
editorConfig.update("semanticTokenColorCustomizations", { rules: semanticTokenRules }, ConfigurationTarget.Global);
}
showWelcomeNotification(context);
languages.setLanguageConfiguration('gauge', { wordPattern: /^(?:[*])([^*].*)$/g });
let gaugeWorkspace = new GaugeWorkspace(new GaugeState(context), cli, clientsMap);

context.subscriptions.push(
gaugeWorkspace,
new ReferenceProvider(clientsMap),
new GenerateStubCommandProvider(clientsMap),
new ConfigProvider(context),
debug.registerDebugConfigurationProvider('gauge',
{
resolveDebugConfiguration: () => {
throw Error("Starting with the Gauge debug configuration is not supported. Please use the 'Gauge' commands instead.");

export async function activate(context: ExtensionContext) {
let cli = CLI.instance();
if (!cli) {
return;
}
let folders = workspace.workspaceFolders;
context.subscriptions.push(new ProjectInitializer(cli));
let hasGaugeProject = folders && folders.some((f) => ProjectFactory.isGaugeProject(f.uri.fsPath));
if (!hasActiveGaugeDocument(window.activeTextEditor) && !hasGaugeProject) return;
if (!cli.isGaugeInstalled() || !cli.isGaugeVersionGreaterOrEqual(MINIMUM_SUPPORTED_GAUGE_VERSION)) {
return showInstallGaugeNotification();
}
showWelcomeNotification(context);
languages.setLanguageConfiguration('gauge', { wordPattern: /^(?:[*])([^*].*)$/g });
let gaugeWorkspace = new GaugeWorkspace(new GaugeState(context), cli, clientsMap);
updateGaugeSemanticTokenColors();

context.subscriptions.push(
gaugeWorkspace,
new ReferenceProvider(clientsMap),
new GenerateStubCommandProvider(clientsMap),
new ConfigProvider(context),
debug.registerDebugConfigurationProvider('gauge',
{
resolveDebugConfiguration: () => {
throw Error("Starting with the Gauge debug configuration is not supported. Please use the 'Gauge' commands instead.");
}
}),
languages.registerDocumentSemanticTokensProvider(
{ language: 'gauge' },
new GaugeSemanticTokensProvider(),
legend
),
workspace.onDidChangeConfiguration((e) => {
if (e.affectsConfiguration("gauge.semanticTokenColors")) {
updateGaugeSemanticTokenColors();
}
})
);
}
);
}

export function deactivate(): Thenable<void> {
const promises: Thenable<void>[] = [];
export function deactivate(): Thenable<void> {
const promises: Thenable<void>[] = [];

for (const {client} of clientsMap.values()) {
promises.push(client.stop());
}
return Promise.all(promises).then(() => undefined);
}
for (const { client } of clientsMap.values()) {
promises.push(client.stop());
}
return Promise.all(promises).then(() => undefined);
}
5 changes: 3 additions & 2 deletions src/gaugeWorkspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,9 @@ export class GaugeWorkspace extends Disposable {
diagnosticCollectionName: 'gauge',
outputChannel: this._outputChannel,
revealOutputChannelOn: RevealOutputChannelOn.Never,
synchronize: {
configurationSection: 'gauge'
},
};
clientOptions.workspaceFolder = workspace.getWorkspaceFolder(Uri.file(folder));
let languageClient = new LanguageClient('gauge', 'Gauge', serverOptions, clientOptions);
Expand Down Expand Up @@ -229,6 +232,4 @@ export class GaugeWorkspace extends Disposable {
}
});
}


}
Loading
Loading