Clangd, Arduino Serial, Conda and FreeRTOS

Hi there!

I am moving my first steps with platformio and I happy about my progresses. I like this tool!

My problem: I have installed platformio through conda and so far, it is working fairly well. I managed to setup pretty much everything (I am using Vim with clangd and I only have an Arduino board) and my aim is to learn a bit of freeRTOS.

I found this and I managed to build this example. I just added #include "Arduino.h" in the source file and I renamed the file as main.cpp.

Although the code builds, it clangd reports two errors.
In the line:
#include <Arduino_FreeRTOS.h>
it says:
In included file: avr/io.h file not found .pio/libdeps/uno/FreeRTOS/src/FreeRTOS...

and in the line
Serial.begin(9600);
it says: Use of undeclared identifier 'Serial'

My platformio.ini follows:

[env:uno]
platform = atmelavr
board = uno
framework = arduino
lib_deps = feilipu/FreeRTOS@^10.5.1-1
build_flags = -Ilib -Isrc

Any help is appreciated!

I found the solution here.
In the platformio.ini I have

build_flags = -Ilib -Isrc --target=avr

then I run pio run -t compiledb to generate the compile_commands.json file, and then I have to remove the --target=avr from the platformio.ini file because otherwise make will produce avr-gcc: error: unrecognized command line option '--target=avr'; did you mean '--target-help'?

If there is a smoother way to achieve this it would be very appreciated!