diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 6943922ce8..0000000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "ftl.startClientOption": "never" -} diff --git a/extensions/vscode/README.md b/extensions/vscode/README.md index f247686e62..97465b72d7 100644 --- a/extensions/vscode/README.md +++ b/extensions/vscode/README.md @@ -41,9 +41,9 @@ Configure the FTL extension by setting the following options in your Visual Stud } ``` -- `ftl.startClientOption`: Controls if and when to automatically start the FTL development server. Available options are "always" and "never". If not set, the extension will prompt to start the server when opening a FTL project. +- `ftl.automaticallyStartServer`: Controls if and when to automatically start the FTL development server. Available options are "always" and "never". If not set, the extension will prompt to start the server when opening a FTL project. ```json { - "ftl.startClientOption": "always" + "ftl.automaticallyStartServer": "always" } ``` diff --git a/extensions/vscode/package.json b/extensions/vscode/package.json index 727fd449d0..5dddb0fa8e 100644 --- a/extensions/vscode/package.json +++ b/extensions/vscode/package.json @@ -4,7 +4,7 @@ "publisher": "ftl", "description": "VSCode extension for FTL", "icon": "images/icon.png", - "version": "0.0.5", + "version": "0.0.6", "repository": { "type": "git", "url": "https://github.com/TBD54566975/ftl-vscode" @@ -37,14 +37,14 @@ }, "description": "Flags to pass to the FTL executable when starting ftl dev" }, - "ftl.startClientOption": { + "ftl.automaticallyStartServer": { "type": "string", "enum": [ "always", "never" ], "default": null, - "description": "Control if and when to automatically start the FTL client." + "description": "Control if and when to automatically start the FTL dev server." } } }, diff --git a/extensions/vscode/src/config.ts b/extensions/vscode/src/config.ts index b9b16807b7..c57d3d25c4 100644 --- a/extensions/vscode/src/config.ts +++ b/extensions/vscode/src/config.ts @@ -14,15 +14,6 @@ export const getProjectOrWorkspaceRoot = async (): Promise => { return "" } - // Check each folder for the 'ftl-project.toml' file - for (const folder of workspaceFolders) { - const workspaceRootPath = folder.uri.fsPath - const ftlProjectPath = await findFileInWorkspace(workspaceRootPath, 'ftl-project.toml') - if (ftlProjectPath) { - return ftlProjectPath.replace('ftl-project.toml', '') - } - } - return workspaceFolders[0].uri.fsPath } diff --git a/extensions/vscode/src/extension.ts b/extensions/vscode/src/extension.ts index 50b10e43c6..e6957005dc 100644 --- a/extensions/vscode/src/extension.ts +++ b/extensions/vscode/src/extension.ts @@ -19,7 +19,8 @@ let statusBarItem: vscode.StatusBarItem let outputChannel: vscode.OutputChannel export async function activate(context: ExtensionContext) { - console.log('"ftl" extension activated') + outputChannel = vscode.window.createOutputChannel("FTL", 'log') + outputChannel.appendLine("FTL extension activated") let restartCmd = vscode.commands.registerCommand( `${clientId}.restart`, @@ -106,14 +107,17 @@ async function FTLPreflightCheck(ftlPath: string) { async function promptStartClient(context: vscode.ExtensionContext) { const configuration = vscode.workspace.getConfiguration('ftl') - const startClientOption = configuration.get('startClientOption') + outputChannel.appendLine(`FTL configuration: ${JSON.stringify(configuration)}`) + const automaticallyStartServer = configuration.get('automaticallyStartServer') - FTLStatus.disabled(statusBarItem) + FTLStatus.stopped(statusBarItem) - if (startClientOption === 'always') { + if (automaticallyStartServer === 'always') { + outputChannel.appendLine(`FTL development server automatically started`) await startClient(context) return - } else if (startClientOption === 'never') { + } else if (automaticallyStartServer === 'never') { + outputChannel.appendLine(`FTL development server not started ('automaticallyStartServer' set to 'never' in settings.json)`) return } @@ -124,25 +128,27 @@ async function promptStartClient(context: vscode.ExtensionContext) { ).then(async (result) => { switch (result) { case 'Always': - configuration.update('startClientOption', 'always', vscode.ConfigurationTarget.Global) + configuration.update('automaticallyStartServer', 'always', vscode.ConfigurationTarget.Global) await startClient(context) break case 'Yes': await startClient(context) break case 'No': - FTLStatus.disabled(statusBarItem) + outputChannel.appendLine('FTL development server disabled') + FTLStatus.stopped(statusBarItem) break case 'Never': - configuration.update('startClientOption', 'never', vscode.ConfigurationTarget.Global) - FTLStatus.disabled(statusBarItem) + outputChannel.appendLine('FTL development server set to never auto start') + configuration.update('automaticallyStartServer', 'never', vscode.ConfigurationTarget.Global) + FTLStatus.stopped(statusBarItem) break } }) } async function startClient(context: ExtensionContext) { - console.log("Starting client") + outputChannel.appendLine("Starting lsp client") FTLStatus.starting(statusBarItem) const ftlConfig = vscode.workspace.getConfiguration("ftl") @@ -150,28 +156,27 @@ async function startClient(context: ExtensionContext) { const workspaceRootPath = await getProjectOrWorkspaceRoot() const resolvedFtlPath = resolveFtlPath(workspaceRootPath, ftlConfig) - console.log('ftl path', resolvedFtlPath) + outputChannel.appendLine(`VSCode workspace root path: ${workspaceRootPath}`) + outputChannel.appendLine(`FTL path: ${resolvedFtlPath}`) const ftlOK = await FTLPreflightCheck(resolvedFtlPath) if (!ftlOK) { - FTLStatus.disabled(statusBarItem) + FTLStatus.stopped(statusBarItem) return } - outputChannel = vscode.window.createOutputChannel("FTL", 'log') - const userFlags = ftlConfig.get("devCommandFlags") ?? [] - const flags = ["--lsp", ...userFlags] + const flags = [...userFlags, "--lsp"] let serverOptions: ServerOptions = { run: { command: `${resolvedFtlPath}`, - args: ["dev", ".", ...flags], + args: ["dev", ...flags], options: { cwd: workspaceRootPath } }, debug: { command: `${resolvedFtlPath}`, - args: ["dev", ".", ...flags], + args: ["dev", ...flags], options: { cwd: workspaceRootPath } }, } @@ -194,7 +199,6 @@ async function startClient(context: ExtensionContext) { clientOptions ) - console.log("Starting client") context.subscriptions.push(client) client.start().then( diff --git a/extensions/vscode/src/status.ts b/extensions/vscode/src/status.ts index 77f184a2bc..72e8a4e7c6 100644 --- a/extensions/vscode/src/status.ts +++ b/extensions/vscode/src/status.ts @@ -1,12 +1,6 @@ import * as vscode from "vscode" export namespace FTLStatus { - export const disabled = (statusBarItem: vscode.StatusBarItem) => { - statusBarItem.text = `$(circle-slash) FTL` - statusBarItem.tooltip = - "FTL is disabled because it requires an 'ftl-project.toml' or 'ftl.toml' file in the workspace." - } - export const starting = (statusBarItem: vscode.StatusBarItem) => { statusBarItem.text = `$(sync~spin) FTL` statusBarItem.tooltip = "FTL is starting..." diff --git a/ftl-project.toml b/ftl-project.toml index 398baf1d2b..fd63b39f22 100644 --- a/ftl-project.toml +++ b/ftl-project.toml @@ -11,8 +11,5 @@ ftl-min-version = "" [modules.echo.configuration] default = "inline://ImFub255bW91cyI" -[executables] - ftl = "" - [commands] startup = ["echo 'FTL startup command ⚡️'"]