vscode-clangd icon indicating copy to clipboard operation
vscode-clangd copied to clipboard

hope to add this feature,add `-I$(find ${workspaceFolder} -name "*.h" -exec dirname {} \; | sort | uniq)` in `Clangd: Fallback Flags `

Open TranErmu opened this issue 2 years ago • 1 comments

image I want to add -I$(find ${workspaceFolder} -name "*.h" -exec dirname {} \; | sort | uniq) in Clangd: Fallback Flags , but it not work , I hope to add this feature because it is really useful

TranErmu avatar Jul 14 '23 17:07 TranErmu

There are two ways to think about this request:

  1. Add support for vscode-clangd (or the clangd server itself) executing an arbitrary command in "fallback flags" via $(command). I don't particularly have an opinion on this, but others may have thoughts on the security aspects.
  2. Add support for some way to achieve what your command is trying to do, which is to add -I flags for every subdirectory of your workspace folder than contains .h files. Something like this has been proposed in https://github.com/clangd/clangd/issues/349 and https://github.com/clangd/clangd/issues/458.

In the meantime, my suggestion would be to put the command into a shell script which generates a clangd config file containing the flags like this:

CompileFlags:
  Add: [
    -Isubdirectory1
    -Isubdirectory2
  ]

and then invoke the script before using clangd (perhaps as part of your project's build).

HighCommander4 avatar Aug 05 '23 19:08 HighCommander4