diff --git a/vscode-extension/package.json b/vscode-extension/package.json index 8c0820f3ca..7ad1044acf 100644 --- a/vscode-extension/package.json +++ b/vscode-extension/package.json @@ -51,10 +51,16 @@ "default": false, "description": "Ignores 'CONST_ASSERT' statement errors" }, - "zscript.alwaysInclude": { + "zscript.defaultIncludePaths": { "scope": "window", "type": "array", - "default": ["std.zh"], + "default": ["include"], + "description": "Global include paths, to be added to compile attempts." + }, + "zscript.defaultIncludeFiles": { + "scope": "window", + "type": "array", + "default": ["include/std.zh"], "description": "Global includes, to be added to compile attempts." }, "zscript.trace.server": { diff --git a/vscode-extension/server/src/server.ts b/vscode-extension/server/src/server.ts index 53eef7ef26..da40bac02b 100644 --- a/vscode-extension/server/src/server.ts +++ b/vscode-extension/server/src/server.ts @@ -86,7 +86,8 @@ connection.onInitialized(() => { interface Settings { installationFolder?: string; printCompilerOutput?: boolean; - alwaysInclude?: Array; + defaultIncludeFiles?: Array; + defaultIncludePaths?: Array; ignoreConstAssert?: boolean; } @@ -151,9 +152,7 @@ function fileMatches(f1:string, f2:string) } async function processScript(textDocument: TextDocument): Promise { - // In this simple example we get the settings for every validate run. const settings = await getDocumentSettings(textDocument.uri); - // The validator creates diagnostics for all uppercase words length 2 and more const text = textDocument.getText(); let includeText = "#option NO_ERROR_HALT on\n#option HEADER_GUARD on\n"; @@ -173,9 +172,15 @@ async function processScript(textDocument: TextDocument): Promise { if (!globalTmpDir) { globalTmpDir = os.tmpdir(); } - if (settings.alwaysInclude) + if (settings.defaultIncludePaths) { - settings.alwaysInclude.forEach(str =>{ + settings.defaultIncludePaths.forEach(str => { + includeText += `#includepath "${str}"\n`; + }); + } + if (settings.defaultIncludeFiles) + { + settings.defaultIncludeFiles.forEach(str =>{ includeText += `#include "${str}"\n`; }); } @@ -188,6 +193,9 @@ async function processScript(textDocument: TextDocument): Promise { fs.writeFileSync(tmpInput, includeText); fs.writeFileSync(tmpScript, text); const exe = os.platform() === 'win32' ? './zscript.exe' : './zscript'; + if (settings.printCompilerOutput) { + console.log(`Attempting to compile buffer:\n-----\n${includeText}\n-----`); + } try { const args = [ '-unlinked',