Skip to content
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@
"@types/chai": "^4.2.12",
"@types/fs-extra": "^9.0.6",
"@types/mocha": "^2.2.48",
"@types/node": "^12.12.6",
"@types/node": "^18.x",
"@types/sinon": "^10.0.6",
"@types/sinon-chai": "^3.2.5",
"@types/vscode": "^1.63.0",
Expand Down
27 changes: 25 additions & 2 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*--------------------------------------------------------------------------------------------*/
'use strict';

import { workspace, ExtensionContext, extensions, window, commands, Uri } from 'vscode';
import { workspace, ExtensionContext, extensions, window, commands, Uri, ConfigurationTarget, env } from 'vscode';

Check warning on line 9 in src/extension.ts

View workflow job for this annotation

GitHub Actions / build (windows-latest)

'env' is defined but never used

Check warning on line 9 in src/extension.ts

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

'env' is defined but never used

Check warning on line 9 in src/extension.ts

View workflow job for this annotation

GitHub Actions / build (macos-latest)

'env' is defined but never used
import {
CommonLanguageClient,
LanguageClientOptions,
Expand Down Expand Up @@ -113,6 +113,7 @@
): SchemaExtensionAPI {
const telemetryErrorHandler = new TelemetryErrorHandler(runtime.telemetry, lsName, 4);
const outputChannel = window.createOutputChannel(lsName);
const l10nPath = context.asAbsolutePath('../yaml-language-server/l10n');
// Options to control the language client
const clientOptions: LanguageClientOptions = {
// Register the server for on disk and newly created YAML documents
Expand All @@ -129,6 +130,9 @@
revealOutputChannelOn: RevealOutputChannelOn.Never,
errorHandler: telemetryErrorHandler,
outputChannel: new TelemetryOutputChannel(outputChannel, runtime.telemetry),
initializationOptions: {
l10nPath,
},
};

// Create the language client and start it
Expand Down Expand Up @@ -157,7 +161,7 @@
findConflicts();
client
.onReady()
.then(() => {
.then(async () => {
// Send a notification to the server with any YAML schema associations in all extensions
client.sendNotification(SchemaAssociationNotification.type, getSchemaAssociations());

Expand Down Expand Up @@ -214,6 +218,8 @@
});

initializeRecommendation(context);

await setDefaultFormatter(['dockercompose', 'github-actions-workflow']);
})
.catch((err) => {
sendStartupTelemetryEvent(runtime.telemetry, false, err);
Expand All @@ -222,6 +228,23 @@
return schemaExtensionAPI;
}

/**
* set redhat.vscode-yaml as default formatter
* @param extensions [dockercompose, github-actions-workflow]
*/
async function setDefaultFormatter(extensions: string[]): Promise<void> {
const config = workspace.getConfiguration();
extensions.forEach(async (extension) => {
const extensionConf = config.get<Record<string, string>>(`[${extension}]`) || {};
if (extensionConf) {
if (extensionConf['editor.defaultFormatter'] === undefined) {
extensionConf['editor.defaultFormatter'] = 'redhat.vscode-yaml';
await config.update(`[${extension}]`, extensionConf, ConfigurationTarget.Global);
}
}
});
}

/**
* Finds extensions that conflict with VSCode-YAML.
* If one or more conflicts are found then show an uninstall notification
Expand Down
15 changes: 11 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -310,10 +310,12 @@
resolved "https://registry.yarnpkg.com/@types/node/-/node-18.15.3.tgz#f0b991c32cfc6a4e7f3399d6cb4b8cf9a0315014"
integrity sha512-p6ua9zBxz5otCmbpb5D3U4B5Nanw6Pk3PPyX05xnxbB/fRv71N7CPmORg7uAD5P70T0xmx1pzAx/FUfa5X+3cw==

"@types/node@^12.12.6":
version "12.20.55"
resolved "https://registry.yarnpkg.com/@types/node/-/node-12.20.55.tgz#c329cbd434c42164f846b909bd6f85b5537f6240"
integrity sha512-J8xLz7q2OFulZ2cyGTLE1TbbZcjpno7FaN6zdJNrgAdrJ+DZzh/uFR6YrTb4C+nXakvud8Q4+rbhoIWlYQbUFQ==
"@types/node@^18.x":
version "18.19.112"
resolved "https://registry.yarnpkg.com/@types/node/-/node-18.19.112.tgz#cd2aee9c075402e0e1942a44101428881dbeb110"
integrity sha512-i+Vukt9POdS/MBI7YrrkkI5fMfwFtOjphSmt4WXYLfwqsfr6z/HdCx7LqT9M7JktGob8WNgj8nFB4TbGNE4Cog==
dependencies:
undici-types "~5.26.4"

"@types/responselike@^1.0.0":
version "1.0.0"
Expand Down Expand Up @@ -4571,6 +4573,11 @@ underscore@^1.12.1:
resolved "https://registry.yarnpkg.com/underscore/-/underscore-1.13.6.tgz#04786a1f589dc6c09f761fc5f45b89e935136441"
integrity sha512-+A5Sja4HP1M08MaXya7p5LvjuM7K6q/2EaC0+iovj/wOcMsTzMvDFbasi/oSapiwOlt252IqsKqPjCl7huKS0A==

undici-types@~5.26.4:
version "5.26.5"
resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-5.26.5.tgz#bcd539893d00b56e964fd2657a4866b221a65617"
integrity sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==

universalify@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/universalify/-/universalify-2.0.0.tgz#75a4984efedc4b08975c5aeb73f530d02df25717"
Expand Down
Loading