diff --git a/package.json b/package.json index 73995fd..780794d 100644 --- a/package.json +++ b/package.json @@ -147,6 +147,11 @@ ], "description": "Specify the list of options used for running benchmarks. --benchmark is implicit." }, + "mesonbuild.modifySettings": { + "type": "boolean", + "default": true, + "description": "Automatically setup other extensions to use files generated by Meson. Disable this if for example .vscode/settings.json is committed into git and should not be modified." + }, "mesonbuild.mesonPath": { "type": "string", "default": "meson", diff --git a/src/extension.ts b/src/extension.ts index c0a054f..db6f950 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -134,21 +134,17 @@ export async function activate(ctx: vscode.ExtensionContext) { const compileCommandsFile = `${buildDir}/compile_commands.json`; whenFileExists(ctx, compileCommandsFile, async () => { - try { + if (extensionConfiguration(SettingsKey.modifySettings)) { const conf = vscode.workspace.getConfiguration("C_Cpp"); conf.update("default.compileCommands", compileCommandsFile, vscode.ConfigurationTarget.Workspace); - } catch { - // Ignore, C/C++ extension might not be installed } }); const rustProjectFile = `${buildDir}/rust-project.json`; whenFileExists(ctx, rustProjectFile, async () => { - try { + if (extensionConfiguration(SettingsKey.modifySettings)) { const conf = vscode.workspace.getConfiguration("rust-analyzer"); conf.update("linkedProjects", [rustProjectFile], vscode.ConfigurationTarget.Workspace); - } catch { - // Ignore, rust-analyzer extension might not be installed } }); diff --git a/src/types.ts b/src/types.ts index ddff3c1..5f0c8d3 100644 --- a/src/types.ts +++ b/src/types.ts @@ -33,6 +33,7 @@ export interface ExtensionConfiguration { languageServerPath: string; downloadLanguageServer: boolean | "ask"; selectRootDir: boolean; + modifySettings: boolean; } export interface TaskQuickPickItem extends vscode.QuickPickItem { @@ -131,4 +132,5 @@ export enum SettingsKey { languageServer = "languageServer", configureOnOpen = "configureOnOpen", selectRootDir = "selectRootDir", + modifySettings = "modifySettings", }