diff --git a/src/checkServerVersion.ts b/src/checkServerVersion.ts index c0db262..b6a55a8 100644 --- a/src/checkServerVersion.ts +++ b/src/checkServerVersion.ts @@ -1,6 +1,7 @@ -import { WorkspaceConfiguration } from "./interfaces/WorkspaceConfiguration"; -import { ConfigurationTarget } from "./interfaces/ConfigurationTarget"; import * as semver from "semver"; +import { ConfigurationTarget } from "./interfaces/ConfigurationTarget"; +import { UserConfiguration } from "./interfaces/UserConfiguration"; +import { WorkspaceConfiguration } from "./interfaces/WorkspaceConfiguration"; interface OnOutdatedParams { message: string; @@ -16,7 +17,7 @@ interface UpdateConfigParams { configurationTarget: ConfigurationTarget; } -const configSection = "serverVersion"; +const configSection = UserConfiguration.ServerVersion; interface CheckServerVersionParams { config: WorkspaceConfiguration; diff --git a/src/detectLaunchConfigurationChanges.ts b/src/detectLaunchConfigurationChanges.ts index 46184ec..4cd9dce 100644 --- a/src/detectLaunchConfigurationChanges.ts +++ b/src/detectLaunchConfigurationChanges.ts @@ -1,3 +1,4 @@ +import { UserConfiguration } from "./interfaces/UserConfiguration"; import { Workspace } from "./interfaces/Workspace"; interface PromptRestartParams { @@ -13,10 +14,11 @@ export function detectLaunchConfigurationChanges( ): void { workspace.onDidChangeConfiguration((e) => { const promptRestartKeys = [ - "serverVersion", - "serverProperties", - "javaHome", - "customRepositories", + UserConfiguration.ServerVersion, + UserConfiguration.ServerProperties, + UserConfiguration.JavaHome, + UserConfiguration.CustomRepositories, + UserConfiguration.CoursierMirror, ...additionalRestartKeys, ]; const shouldPromptRestart = promptRestartKeys.some((key) => diff --git a/src/getJavaConfig.ts b/src/getJavaConfig.ts index 647140f..f35524a 100644 --- a/src/getJavaConfig.ts +++ b/src/getJavaConfig.ts @@ -5,6 +5,7 @@ export interface JavaConfig { javaOptions: string[]; javaPath: string; coursierPath: string; + coursierMirrorFilePath: string | undefined; extraEnv: { [k: string]: string | undefined; }; @@ -14,6 +15,7 @@ interface GetJavaConfigOptions { workspaceRoot: string | undefined; javaHome: string; extensionPath: string; + coursierMirrorFilePath: string | undefined; customRepositories: string[] | undefined; } @@ -21,6 +23,7 @@ export function getJavaConfig({ workspaceRoot, javaHome, extensionPath, + coursierMirrorFilePath, customRepositories = [], }: GetJavaConfigOptions): JavaConfig { const javaOptions = getJavaOptions(workspaceRoot); @@ -28,6 +31,7 @@ export function getJavaConfig({ const coursierPath = path.join(extensionPath, "./coursier"); const extraEnv = { COURSIER_REPOSITORIES: customRepositories.join("|"), + COURSIER_MIRRORS: coursierMirrorFilePath, JAVA_HOME: javaHome, }; @@ -35,6 +39,7 @@ export function getJavaConfig({ javaOptions, javaPath, coursierPath, + coursierMirrorFilePath, extraEnv, }; } diff --git a/src/interfaces/ClientCommands.ts b/src/interfaces/ClientCommands.ts index 9ef854c..3e73e65 100644 --- a/src/interfaces/ClientCommands.ts +++ b/src/interfaces/ClientCommands.ts @@ -2,7 +2,7 @@ * These are all of the client commands that Metals supports. Note that not support * may vary based on the `InitializationSettings` the client sets. * - * - https://scalameta.org/metals/docs/editors/new-editor.html#metals-client-commands + * - https://scalameta.org/metals/docs/integrations/new-editor#metals-client-commands */ export const ClientCommands = { /** diff --git a/src/interfaces/UserConfiguration.ts b/src/interfaces/UserConfiguration.ts new file mode 100644 index 0000000..72c1b41 --- /dev/null +++ b/src/interfaces/UserConfiguration.ts @@ -0,0 +1,28 @@ +/** + * These are some of the common user configuration options used in Metals and needed for the editors. + * + * - https://scalameta.org/metals/docs/integrations/new-editor#metals-user-configuration + */ +export enum UserConfiguration { + /** + * Metals server version + */ + ServerVersion = "serverVersion", + /** + * Metals server Java properties + */ + ServerProperties = "serverProperties", + /** + * Directory containing the Java binary. + */ + JavaHome = "javaHome", + /** + * Additional repositories that can be used to download dependencies. + * https://get-coursier.io/docs/other-repositories + */ + CustomRepositories = "customRepositories", + /** + * Repository to use instead of maven central for example `https://jcenter.bintray.com` + */ + CoursierMirror = "coursierMirror", +}