You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There has been a long standing issue when using clangd instead of IntelliSense in that clangd doesn't have the necessary info to determine the active config from compile_commands.json alone. AFAIK, it doesn't have anything similar to the configuration provider API that's provided by cpptools. The problem is that Ninja Multi-Config will write all commands for all configs into a single database but when switching configs via cmake-tools, the clangd extension has no idea what config is currently active, so it will simply always grab the first entry for some source file it finds and then runs with the flags provided.
Now, one obvious way to "fix" that is to simply use Ninja, but that defeats the purpose of this discussion.
One workaround that's okay, albeit pretty inconvenient, is to have a per-config task that runs some tool to do the filtering and then rewrites .clangd to let CompilationDatabase point to the correct folder with the stripped JSON, and then restarts clangd, but that means tedious task setup and manually triggering them every time one switches configs, which is annoying and error-prone.
Another way would be to write a small extension that listens to onSelectedConfigurationChanged using the public API and then do the stuff that needs to be done. That, however, is pretty cumbersome and necessitates extension management.
I think the easiest would be to run some custom script or a task when configurations are switched. Do you think it feasible to add a mechanism to trigger something user-provided to help with this?
I don't think the team around clangd will go down the road to add a configuration provider API, since they are and likely will remain centered around a compilation database (or compile_flags.txt in simple cases).
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Hey all!
There has been a long standing issue when using
clangdinstead ofIntelliSensein thatclangddoesn't have the necessary info to determine the active config fromcompile_commands.jsonalone. AFAIK, it doesn't have anything similar to the configuration provider API that's provided bycpptools. The problem is thatNinja Multi-Configwill write all commands for all configs into a single database but when switching configs viacmake-tools, theclangdextension has no idea what config is currently active, so it will simply always grab the first entry for some source file it finds and then runs with the flags provided.Now, one obvious way to "fix" that is to simply use
Ninja, but that defeats the purpose of this discussion.One workaround that's okay, albeit pretty inconvenient, is to have a per-config task that runs some tool to do the filtering and then rewrites
.clangdto letCompilationDatabasepoint to the correct folder with the stripped JSON, and then restartsclangd, but that means tedious task setup and manually triggering them every time one switches configs, which is annoying and error-prone.Another way would be to write a small extension that listens to
onSelectedConfigurationChangedusing the public API and then do the stuff that needs to be done. That, however, is pretty cumbersome and necessitates extension management.I think the easiest would be to run some custom script or a task when configurations are switched. Do you think it feasible to add a mechanism to trigger something user-provided to help with this?
I don't think the team around
clangdwill go down the road to add a configuration provider API, since they are and likely will remain centered around a compilation database (or compile_flags.txt in simple cases).All reactions