diff --git a/src/extension.mts b/src/extension.mts index a4d97379..20372ceb 100644 --- a/src/extension.mts +++ b/src/extension.mts @@ -176,15 +176,12 @@ export async function activate(context: ExtensionContext): Promise { const workspaceFolder = workspace.workspaceFolders?.[0]; - // check if is a pico project - if ( - workspaceFolder === undefined || - !existsSync(join(workspaceFolder.uri.fsPath, "pico_sdk_import.cmake")) - ) { + // check if there is a workspace folder + if (workspaceFolder === undefined) { // finish activation Logger.warn( LoggerSource.extension, - "No workspace folder or Pico project found." + "No workspace folder found." ); await commands.executeCommand( "setContext", @@ -210,6 +207,25 @@ export async function activate(context: ExtensionContext): Promise { return; } + // check for pico_sdk_init() in CMakeLists.txt + if ( + !readFileSync(cmakeListsFilePath) + .toString("utf-8") + .includes("pico_sdk_init()") + ) { + Logger.warn( + LoggerSource.extension, + "No pico_sdk_init() in CMakeLists.txt found." + ); + await commands.executeCommand( + "setContext", + ContextKeys.isPicoProject, + false + ); + + return; + } + // check if it has .vscode folder and cmake donotedit header in CMakelists.txt if ( !existsSync(join(workspaceFolder.uri.fsPath, ".vscode")) ||