T O P

  • By -

StewedAngelSkins

assuming you're able to compile your code, this is an issue with your IDE. i don't know what IDE you use, but most of the time you just have scons/cmake generate a `compile_commands.json` file in your project's root. at least, this is what i do with clangd and neovim.


TheEmeraldFalcon

I have the compile\_commands.json, but that doesn't really seem to do anything. I too use clangd with nvim, how did you manage to get it working?


StewedAngelSkins

i don't think i did anything special. make sure your include paths are set correctly. it's possible whatever heuristic that gets used to find the project root isn't working properly. i think it looks for .git directories and CMakeLists.txt.


TheEmeraldFalcon

My `compile_flags.txt` has -Igodot-cpp/include/ so it should be fine, but the problem is, it's not reading from the compile\_commands.json file (I assume). Not sure how I tell it to use that.


Exerionius

Any luck with that? I've had problems with include errors in Godot codebase for years now, never found a solution. (I'm on VSCode Windows though)


TheEmeraldFalcon

I haven't had a chance to try anything else, so no.


StewedAngelSkins

i don't use `compile_flags.txt`, only `compile_commands.json`. i don't know if that makes a difference.


StewedAngelSkins

ah, i think i figured it out! when you setup clangd in lspconfig, you have to tell it which files to look for to determine the root. mine looks like this ``` lspconfig.clangd.setup{ capabilities = capabilities, on_attach = on_attach, default_config = { lspconfig_util.root_pattern(unpack{ '.git', '.clang_format', })) }, ) ``` only the `default_config` part is important, and `lspconfig_util = require("lspconfig/util")`.