I’m new to esphome and indeed platformio, but not to embedded programming, so apologies if this is too obvious.
I’m trying to get my development environment up and going and need to generate the compile_commands.json file to seed my LSP (CCLS) for code navigation and completion etc,…
Thanks for your suggestion - I have issues getting onto Discord - I always get caught in Authentication loops - I don’t think they like people who use the privacy settings in their browser.
For reference I worked out the answer to my question:
when you build with esphome compile path/to/your.yaml it will create a directory .esphome under that directory (eg path/to/your/.esphome) which will include a build directory for your project (based on the esphome: name: that is resolved in from your yaml) - eg for mine it was esp1.
in that directory - .esphome/build/esp1 in my case - is your platformio project that is generated by esphome. You can follow the instructions here to generate compile_commands.json. You’ll need the toolchain includes to be added too.
You’ll probably have to massage some paths as esphome copies your file from where your editor is to underneath that .esphome/build/<your device> directory.
Additionally clang chokes on some gcc command-line parameters so you may have to drop some -f and optimisation parameters
Though I had no luck actually getting ccls to run as the clang version in use has no support for the esp32 and it stumbles over the system includes.