question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

support commands in settings

See original GitHub issue

For proper CMake support we would need "clangd.arguments": [ "--compile-commands-dir=${command:cmake.launchTargetDirectory}" ]. https://github.com/microsoft/vscode-cmake-tools/issues/654

Problem is that invoking commands is async so you can’t just add this in config.ts:

const cmdPrefix = 'command:';
if (name.startsWith(cmdPrefix))
    return await vscode.commands.executeCommand(name.substr(cmdPrefix.length));

Btw, looks like the relevant vscode feature request is https://github.com/microsoft/vscode/issues/46471.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:6
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
abdescommented, Dec 7, 2021

he biggest problem here is there’s no principled way to even figure out a project root in the absence of a compile_commands.json. We can make use of other heuristics like existence of …

Please note that in a multi-config build environment the problem is not the project root, but rather the build output root for each config.

For example, in my case (cmake + clangd + vscode + cmake-tools), I definitely want my build to be out of source and each build config in its separate build tree (e.g. windows, linux, dev, release, valgrind, etc…).

The one responsible for generating the compilation database is cmake. CMake knows everything about the project, its source, its build output, etc…

The one that invokes cmake is cmake-tools, which knows about the CMakePresets.json which has the source dir, build, dir, preset name, and many more info about the presets. My understanding is that the whole point from this issue is to use such info through a substitution with command in vscode settings.json.

The one who uses compiler_commands.json is clangd and clangd has no idea where cmake is putting that file, and the settings in vscode are so limited that we can only (right now) hardcode a directory for clangd to look into.

So at the end of the day, imho, it’s not really clangd’s responsibility to figure out where cmake puts its babies. Inside vscode it’s just a pity that there is no such seamless integration happening between cmake, cmake-tools, clangd and vscode.

Outside of vscode, I don’t know whether there is a universal solution for this problem, but a good compromise is when clangd is working in a cmake environment and that environment has a CMakePresets.json. That presets file could be used by clangd to get a lot of info. That’s exactly how Visual Studio for example integrates cmake now…

To conclude, I really appreciate what you guys are doing and it’s just so great to have clangd in vscode that I wanted it to be not just great, but perfect 😃

0reactions
ahfaktcommented, Dec 25, 2022

Do developers think about to implement ${command:…} substitution? “cmake.copyCompileCommands” alternative works but having to use it is still uncomfortable.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to customize Voice Control commands on your ...
Go to Settings. Select Accessibility, then select Voice Control. Select Customize Commands, then go through the list of commands.
Read more >
Command Line Tool Support - WebStorm - JetBrains
Windows and Linux: File | Settings | Tools | Command Line Tool Support. macOS: WebStorm | Preferences | Tools | Command Line Tool...
Read more >
Viewing support assistance settings - IBM
In the management GUI, click Settings > Support > Support Assistance. The Support Assistance window is displayed, which shows the support assistance settings....
Read more >
get-service-settings — AWS CLI 1.27.27 Command Reference
--cli-input-json (string) Performs service operation based on the JSON string provided. The JSON string follows the format provided by --generate-cli-skeleton .
Read more >
Dell Command | Update Version 4.x User's Guide | Dell US
Default source location from Dell Support Site. Internet Proxy, Use current Internet proxy settings. User Consent, Varies based on the selection during ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found