Config file for multiple boards, platforms and frameworks

Context

I am trying to make a library for a board that is controlled over UART. The library is hardware and framework agnostic with hardware abstraction layers included for some platforms, Arduino and ESP-IDF for now. I have several Arduino and Espresiff boards lying around that I can test my library with, STM and Teensy are on the way.

I have an Examples directory with Arduino and esp32 examples inside. And a src directory containing my library (Arduino IDE wants it to be there or in root, not in lib) in case the library is used with Arduino IDE.

I have created platformio.ini file with global settings, a default [env] and I’m trying to override settings per environment. I can now run pio run and my library is compiles just fine, all the frameworks are automatically installed, great…

Problem

I’m using VSCode and, my c_cpp_properties.json file contains only include directories related to the first env in my platformio.ini file. So intellisense only works for e.g. Arduino headers… When I work on ESP32 files I have to change the order of the envs to get suggestions. Very annoying.

I tried adding multiple platform_packages at the gloval and [env] level to no avail (I hoped listing them all would put all of them in the includePath).

I’m looking for a tip, a boilerplate config, or an insight to improve the situation a bit. Normally the “you are trying to do “a” with “b”, but you should really be using “x” with “y”.” answers are annoying to receive but I realise that maybe I’m just using platformio wrong so I am very open to suggestions…

My config file:

[platformio]
src_dir = examples
lib_dir = src
; This does not seem to help at all
platform_packages = toolchain-atmelavr, framework-espidf, framework-arduinoespressif32, framework-arduinoespressif8266
framework = arduino, espidf

[env]
; For Arduino (most common env in the list so it is the default)
src_filter = +<*> -<esp32/>

; This boards framework is in the includePath of c_cpp_properties.json 
[env:pro16MHzatmega328]
platform = atmelavr
board = pro16MHzatmega328
framework = arduino

; This one is not in the includePath but compiles fine.
[env:nodemcu-32s-esp-idf]
platform = espressif32
platform_packages = framework-espidf
framework = espidf
board = nodemcu-32s
src_filter = +<esp32/>

[env:uno]
platform = atmelavr
framework = arduino
board = uno

[env:nodemcu-32s-arduino]
platform = espressif32
platform_packages = framework-arduinoespressif32
framework = arduino
board = nodemcu-32s

[env:nodemcu-arduino]
platform = espressif8266
platform_packages = framework-arduinoespressif8266
framework = arduino
board = nodemcu

You can switch between envs Redirecting...