Skip to content

Commit 5496edb

Browse files
authored
Merge pull request #62 from bcmi-labs/setup_cpp
Configure cpp extension to use embedded clangd
2 parents 2220e66 + 62eff29 commit 5496edb

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

arduino-ide-extension/src/node/arduino-backend-module.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import * as fs from 'fs';
2+
import * as os from 'os';
3+
import { join } from 'path';
14
import { ContainerModule } from 'inversify';
25
import { ArduinoDaemon } from './arduino-daemon';
36
import { ILogger } from '@theia/core/lib/common/logger';
@@ -155,4 +158,13 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
155158
const parentLogger = ctx.container.get<ILogger>(ILogger);
156159
return parentLogger.child('monitor-service');
157160
}).inSingletonScope().whenTargetNamed('monitor-service');
161+
162+
// Set up cpp extension
163+
if (!process.env.CPP_CLANGD_COMMAND) {
164+
const executable = os.platform() === 'win32' ? 'clangd.exe' : 'clangd';
165+
const clangdCommand = join(__dirname, '..', '..', 'build', executable);
166+
if (fs.existsSync(clangdCommand)) {
167+
process.env.CPP_CLANGD_COMMAND = clangdCommand;
168+
}
169+
}
158170
});

0 commit comments

Comments
 (0)