Skip to content

Commit 78cfb5d

Browse files
authored
Add option to suppress warning about the Microsoft C/C++ extension incompatibility (#221)
1 parent 7bad7cb commit 78cfb5d

File tree

2 files changed

+36
-18
lines changed

2 files changed

+36
-18
lines changed

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,11 @@
148148
"Automatically restart the server",
149149
"Do nothing"
150150
]
151+
},
152+
"clangd.detectExtensionConflicts": {
153+
"type": "boolean",
154+
"default": true,
155+
"description": "Warn about conflicting extensions and suggest disabling them."
151156
}
152157
}
153158
},

src/extension.ts

Lines changed: 31 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -27,23 +27,36 @@ export async function activate(context: vscode.ExtensionContext) {
2727
await clangdContext.activate(context.globalStoragePath, outputChannel,
2828
context.workspaceState);
2929

30-
setInterval(function() {
31-
const cppTools = vscode.extensions.getExtension('ms-vscode.cpptools');
32-
if (cppTools && cppTools.isActive) {
33-
const cppToolsConfiguration = vscode.workspace.getConfiguration('C_Cpp');
34-
const cppToolsEnabled = cppToolsConfiguration.get('intelliSenseEngine');
35-
if (cppToolsEnabled !== 'Disabled') {
36-
vscode.window
37-
.showWarningMessage(
38-
'You have both the Microsoft C++ (cpptools) extension and ' +
39-
'clangd extension enabled. The Microsoft IntelliSense features ' +
40-
'conflict with clangd\'s code completion, diagnostics etc.',
41-
'Disable IntelliSense')
42-
.then(_ => {
43-
cppToolsConfiguration.update('intelliSenseEngine', 'Disabled',
44-
vscode.ConfigurationTarget.Global);
45-
});
30+
const shouldCheck = vscode.workspace.getConfiguration('clangd').get(
31+
'detectExtensionConflicts');
32+
if (shouldCheck) {
33+
const interval = setInterval(function() {
34+
const cppTools = vscode.extensions.getExtension('ms-vscode.cpptools');
35+
if (cppTools && cppTools.isActive) {
36+
const cppToolsConfiguration =
37+
vscode.workspace.getConfiguration('C_Cpp');
38+
const cppToolsEnabled = cppToolsConfiguration.get('intelliSenseEngine');
39+
if (cppToolsEnabled !== 'Disabled') {
40+
vscode.window
41+
.showWarningMessage(
42+
'You have both the Microsoft C++ (cpptools) extension and ' +
43+
'clangd extension enabled. The Microsoft IntelliSense features ' +
44+
'conflict with clangd\'s code completion, diagnostics etc.',
45+
'Disable IntelliSense', 'Never show this warning')
46+
.then(selection => {
47+
if (selection == 'Disable IntelliSense') {
48+
cppToolsConfiguration.update(
49+
'intelliSenseEngine', 'Disabled',
50+
vscode.ConfigurationTarget.Global);
51+
} else if (selection == 'Never show this warning') {
52+
vscode.workspace.getConfiguration('clangd').update(
53+
'detectExtensionConflicts', false,
54+
vscode.ConfigurationTarget.Global);
55+
clearInterval(interval);
56+
}
57+
});
58+
}
4659
}
47-
}
48-
}, 5000);
60+
}, 5000);
61+
}
4962
}

0 commit comments

Comments
 (0)