I am currently trying to setup a .clangd file to use for my lsp ...
how can i add multiple compile flags? my file is autogenerated and looks like this:
CompileFlags:
Add:
- -IC:\Users\adria\Desktop\Nimble_New\include
- -IC:\Users\adria\Desktop\Nimble_New\include\lua
- -IC:\Users\adria\Desktop\Nimble_New\include\raylib
- -IC:\Users\adria\Desktop\Nimble_New\include\rlimgui
- -IC:\Users\adria\Desktop\Nimble_New\include\rlimgui\extras
- -IC:\Users\adria\Desktop\Nimble_New\src
- -IC:\Users\adria\Desktop\Nimble_New\src\asseteditor
- -IC:\Users\adria\Desktop\Nimble_New\src\textureeditor
- -IC:\Users\adria\Desktop\Nimble_New\src\ui
- -IC:\Users\adria\Desktop\Nimble_New\src\utils
I also tried it this way:
CompileFlags:
Add: [-IC:\Users\adria\Desktop\Nimble_New\include,-IC:\Users\adria\Desktop\Nimble_New\include\lua,-IC:\Users\adria\Desktop\Nimble_New\include\raylib,-IC:\Users\adria\Desktop\Nimble_New\include\rlimgui,-IC:\Users\adria\Desktop\Nimble_New\include\rlimgui\extras,-IC:\Users\adria\Desktop\Nimble_New\src,-IC:\Users\adria\Desktop\Nimble_New\src\asseteditor,-IC:\Users\adria\Desktop\Nimble_New\src\textureeditor,-IC:\Users\adria\Desktop\Nimble_New\src\ui,-IC:\Users\adria\Desktop\Nimble_New\src\utils]
If i do:
CompileFlags:
Add: -IC:\Users\adria\Desktop\Nimble_New\include\raylib
Or:
CompileFlags:
Add:
- -IC:\Users\adria\Desktop\Nimble_New\include\raylib
it works just fine for one include path but as soon as i add another one it doesnt load anymore.
Is there another solution to this?
I fixed it by creating a compile_flags.txt in the source directory which has following content:
-IC:\Users\adria\Desktop\Nimble_New\include
-IC:\Users\adria\Desktop\Nimble_New\include\lua
-IC:\Users\adria\Desktop\Nimble_New\include\raylib
-IC:\Users\adria\Desktop\Nimble_New\include\rlimgui
-IC:\Users\adria\Desktop\Nimble_New\include\rlimgui\extras
-IC:\Users\adria\Desktop\Nimble_New\src
-IC:\Users\adria\Desktop\Nimble_New\src\asseteditor
-IC:\Users\adria\Desktop\Nimble_New\src\textureeditor
-IC:\Users\adria\Desktop\Nimble_New\src\ui
-IC:\Users\adria\Desktop\Nimble_New\src\utils
simple as that i can use my lsp without problems with clangd
for anyone having the same issue i automated the creation of the file with a simple python file:
import os
dir_path = os.path.dirname(os.path.realpath(__file__))
include_paths = []
for path, subdirs, files in os.walk(f"{dir_path}\\include"):
if path not in include_paths:
include_paths.append(path)
for path, subdirs, files in os.walk(f"{dir_path}\\src"):
if path not in include_paths:
include_paths.append(path)
with open("compile_flags.txt", mode="w", encoding="utf-8") as file:
for path in include_paths:
file.write(f'-I{path}\n')
just run it in source dir, you can edit the folder paths "include" and "source" by your needs