Bear gives you working code navigation, autocomplete, and diagnostics on any C/C++ project, whatever the build system. Prefix your build command withbear --and it produces thecompile_commands.jsonfile that Clang tooling (clangd, clang-tidy, and friends) needs to understand your code.
It sure is interesting that there needs to be all these sorts of helper third party things to make working in C/C++ not painful. I’m only now finding out about Bear (Build EAR). In previous C++ or C work (class assignments), I’ve just coped when the LSP can’t pick things up automatically. I miss environments like the Python and Rust ones where the LSP defaults have Just Worked out of the box.
For CLion, you can run e.g. bear -- make and then open the resulting compile_commands.json with CLion directly (i.e. via File → Open). It’ll prompt to open as a project or something. Pretty helpful.
Apparently Bear has some historic issues on MacOS because of security policies? Hoping I don’t run into those in the future. This looks like it solved my one “LSP can’t find an included header file that was declared in the Makefile” issue, so good enough for me then.
Edit from about two seconds later: lol. Lmao. As it turns out, trying to run the program via the IDE loads a faulty configuration (the original one, the one that can’t detect the included header path). This also brings back the bad LSP error. And now, the only way I know to bring it back is to just delete that auto-added configuration. What a bit of nonsense. I guess I’ll only build via command line, and then be sad if I want to IDE debug. Will have to figure out that some other time.