diff --git a/extension/README.md b/extension/README.md index 171e7ebb..3704c967 100644 --- a/extension/README.md +++ b/extension/README.md @@ -48,6 +48,11 @@ version that built keeps running until you fix them. To use code you already have, open its folder: the extension detects the appropriate platform and main file. +You don't need Microsoft's C/C++ extension: this extension builds your C code +and reports its errors. VS Code suggests C/C++ whenever you open a `.c` file, +so new projects include a `.vscode/extensions.json` that turns the suggestion +off for that folder. Elsewhere, you can safely dismiss it. + ## Settings Project settings, saved in `.vscode/settings.json`: diff --git a/extension/src/extension.ts b/extension/src/extension.ts index 6e2118f2..9fd5b2b5 100644 --- a/extension/src/extension.ts +++ b/extension/src/extension.ts @@ -973,6 +973,22 @@ async function writeFolderSettings(dir: vscode.Uri, s: { platform: string, mainF if (s.tool) json[CONFIG + '.tool'] = s.tool; await vscode.workspace.fs.createDirectory(vscode.Uri.joinPath(dir, '.vscode')); await vscode.workspace.fs.writeFile(file, new TextEncoder().encode(JSON.stringify(json, null, 2) + '\n')); + await writeExtensionRecommendations(dir); +} + +/** + * VS Code offers the C/C++ extension for every .c file, but its IntelliSense + * can't find cc65/SDCC headers and only adds false errors. Declining it in + * .vscode/extensions.json is the only way to stop the prompt for a folder. + */ +async function writeExtensionRecommendations(dir: vscode.Uri) { + var file = vscode.Uri.joinPath(dir, '.vscode', 'extensions.json'); + try { await vscode.workspace.fs.stat(file); return; } catch (e) { } // leave the user's alone + var json = { + recommendations: ['8bitworkshop.8bitworkshop'], + unwantedRecommendations: ['ms-vscode.cpptools', 'ms-vscode.cpptools-extension-pack'], + }; + await vscode.workspace.fs.writeFile(file, new TextEncoder().encode(JSON.stringify(json, null, 2) + '\n')); } async function changeMainFile() {