Hey,same situation here. I am not an emacs expert but am using it for around 6 years now.
My solution is to use clangd with a "compile_flags.txt" file in top level directory of the repository (and add it to ".git/info/exclude") to avoid an accidential commit.
The content is mostly project paths and additionally:
-include
c:/Users/USERNAME/.mchp_packs/Microchip/dsPICxxx/y.y.yyy/COMPILER/support/dsPICxxx/h/pxxx.h
-include
c:/Users/USERNAME/.mchp_packs/Microchip/dsPICxxx/y.y.yyy/COMPILER/support/generic/h/xc.h
-I
path/to/project.X/mcc_generated_files
-O0
-I
C:/MinGW/include
-D
__dsPICxxx__
The paths vary in Controller and pack that is used.
I also use "eglot" instead of "lsp-mode" simply because it's enough for me in functionality and I also have a "build.bat" at the top level of the repo that is used with the emacs internal compile command like "project-compile" (C-c p c).
- build.bat clean
- build.bat cleanbuild
- build.bat makefiles
- build.bat ...