Suppose i have a project with and src folder to keep all my code, and an include folder to store third-party libraries.
Let's say there is a file include/TestLib/lib.hpp with the following code:
// lib.hpp
#include <string>
#include <iostream>
void Log(std::string text){
std::cout << text << std::endl;
}
and the other file is src/main.cpp:
#include "../include/TestLib/lib.hpp"
int main(){
Log("Hello world");
}
In order for it to not give errors on neovim i have to use the full path of all hpp files. Premake allows me to use include directories to avoid using that and only needing to do as follows:
#include "lib.hpp"
int main(){
Log("Hello world");
}
When i build it, it compiles correctly, however neovim/clangd is not able to find the include directories. How can i tell clangd where to look for those files?
For anyone with the same problem, you just need the compile_commands.json file on the root of the project. Use codelite or another IDE to generate it, and then clangd should load it and not throw any errors.