Skip to content

Commit

Permalink
Add modifySettings setting
Browse files Browse the repository at this point in the history
  • Loading branch information
xclaesse committed Dec 5, 2023
1 parent 6433673 commit fe779b8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
8 changes: 2 additions & 6 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
});

Expand Down
2 changes: 2 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export interface ExtensionConfiguration {
languageServerPath: string;
downloadLanguageServer: boolean | "ask";
selectRootDir: boolean;
modifySettings: boolean;
}

export interface TaskQuickPickItem extends vscode.QuickPickItem {
Expand Down Expand Up @@ -131,4 +132,5 @@ export enum SettingsKey {
languageServer = "languageServer",
configureOnOpen = "configureOnOpen",
selectRootDir = "selectRootDir",
modifySettings = "modifySettings",
}

0 comments on commit fe779b8

Please sign in to comment.