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
62 changes: 50 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,14 @@
},
"configuration": {
"type": "object",
"title": "vscode-smithy configuration",
"title": "Smithy",
"properties": {
"smithyLsp.maxNumberOfProblems": {
"scope": "resource",
"type": "number",
"default": 100,
"description": "Controls the maximum number of problems produced by the server."
"description": "Controls the maximum number of problems produced by the server.",
"deprecationMessage": "Use smithy.maxNumberOfProblems instead."
},
"smithyLsp.trace.server": {
"scope": "window",
Expand All @@ -101,17 +102,15 @@
"verbose"
],
"default": "verbose",
"description": "Traces the communication between VS Code and the language server."
"description": "Traces the communication between VS Code and the language server.",
"deprecationMessage": "Use smithy.trace.server instead."
},
"smithyLsp.version": {
"scope": "window",
"type": "string",
"default": "0.6.0",
"description": "Version of the Smithy Language Server (see https://github.com/smithy-lang/smithy-language-server)."
},
"smithyLsp.rootPath": {
"scope": "resource",
"type": "string"
"default": null,
"description": "Version of the Smithy Language Server (see https://github.com/smithy-lang/smithy-language-server).",
"deprecationMessage": "Use smithy.server.version instead."
},
"smithyLsp.diagnostics.minimumSeverity": {
"scope": "window",
Expand All @@ -122,14 +121,53 @@
"DANGER",
"ERROR"
],
"default": "WARNING",
"description": "Minimum severity of Smithy validation events to display in the editor."
"default": null,
"description": "Minimum severity of Smithy validation events to display in the editor.",
"deprecationMessage": "Use smithy.server.diagnostics.minimumSeverity instead."
},
"smithyLsp.onlyReloadOnSave": {
"scope": "window",
"type": "boolean",
"default": false,
"description": "Whether to only re-load the Smithy model on save. Use this if the server feels slow as you type."
"description": "Whether to only re-load the Smithy model on save. Use this if the server feels slow as you type.",
"deprecationMessage": "May cause features like definition, hover, and completions to behave incorrectly when you have unsaved changes."
},
"smithy.maxNumberOfProblems": {
"scope": "resource",
"type": "number",
"default": 100,
"description": "Controls the maximum number of problems produced by the server."
},
"smithy.trace.server": {
"type": "string",
"enum": [
"off",
"messages",
"verbose"
],
"default": "verbose",
"description": "Traces the communication between VS Code and the language server."
},
"smithy.server.executable": {
"type": "string",
"default": null,
"description": "Executable to run the Smithy Language Server. Can be the executable name if it is on your PATH, or an absolute path to the executable."
},
"smithy.server.version": {
"type": "string",
"default": "0.6.0",
"description": "Version of the Smithy Language Server to use. Ignored if smithy.server.executable is provided."
},
"smithy.server.diagnostics.minimumSeverity": {
"type": "string",
"enum": [
"NOTE",
"WARNING",
"DANGER",
"ERROR"
],
"default": "WARNING",
"description": "Minimum severity of Smithy validation events to display in the editor."
}
}
}
Expand Down
29 changes: 29 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import * as vscode from 'vscode';

export function getServerDiagnosticsMinimumSeverity(): string | undefined {
return getOldOrNewConfig('diagnostics.minimumSeverity', 'server.diagnostics.minimumSeverity');
}

export function getServerOnlyReloadOnSave(): boolean | undefined {
return getOldConfig('onlyReloadOnSave');
}

export function getServerExecutable(): string | undefined {
return getConfig('server.executable');
}

export function getServerVersion(): string {
return getOldOrNewConfig('version', 'server.version');
}

function getOldOrNewConfig<T>(oldKey: string, newKey: string): T | undefined {
return getOldConfig(oldKey) || getConfig(newKey);
}

function getConfig<T>(key: string): T | undefined {
return vscode.workspace.getConfiguration('smithy').get<T>(key);
}

function getOldConfig<T>(key: string): T | undefined {
return vscode.workspace.getConfiguration('smithyLsp').get<T>(key);
}
26 changes: 18 additions & 8 deletions src/coursier/coursier.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
import { downloadCoursierIfRequired } from './download-coursier';
import { findCoursierOnPath } from './path-check';
import * as child_process from 'child_process';
import * as vscode from 'vscode';
import downloadCoursierIfRequired from './download-coursier';

export function getCoursierExecutable(extensionPath: string): Promise<string> {
return findCoursierOnPath(extensionPath).then((paths) => {
if (paths.length > 0) {
return paths[0];
} else {
return downloadCoursierIfRequired(extensionPath, 'v2.0.6');
export default async function getCoursierExecutable(context: vscode.ExtensionContext): Promise<string> {
for (const command of ['cs', 'coursier']) {
if (await availableOnPath(command, ['--help'])) {
return command;
}
}

console.log('Coursier not found on path, downloading it instead.');
return await downloadCoursierIfRequired(context.globalStoragePath, 'v2.0.6');
}

function availableOnPath(command: string, args: string[]): Promise<boolean> {
return new Promise((resolve, reject) => {
child_process.execFile(command, args, (e, _, __) => {
resolve(e == null);
});
});
}
2 changes: 1 addition & 1 deletion src/coursier/download-coursier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { IncomingMessage } from 'http';
import * as fs from 'fs';
import { access, mkdir } from 'fs/promises';

export function downloadCoursierIfRequired(extensionPath: string, versionPath: string): Promise<string> {
export default function downloadCoursierIfRequired(extensionPath: string, versionPath: string): Promise<string> {
function binPath(filename: string) {
return path.join(extensionPath, filename);
}
Expand Down
41 changes: 0 additions & 41 deletions src/coursier/path-check.ts

This file was deleted.

Loading