Header file from installed library not found on Emacs (syntax highlighting)


I’m new to platform io and I am having problems making the emacs lsp recognize the installed library header files. It builds and uploads alright, but the syntax highlighting is off.

I’ve searched for similar problems, but not found anything that solves exactly this problem.

In my case I am getting a red underlined #include "DHT.h" and the message DHT.h not found.

Dependency graph:

Dependency Graph
|-- DHT sensor library @ 1.4.4
|   |-- Adafruit Unified Sensor @ 1.1.7
|-- Adafruit Unified Sensor @ 1.1.7

I am using ccls (as instructed in the platformio emacs documentation).

‘Arduino.h’ is found out of the box without any problems and gives no error (as long as I use ccls).

If I do pio run -t compiledb, that I saw suggested somewhere on the forum, and then open the file I get the messages

LSP :: ccls:7394 initialized successfully in folders: (/home/espen/code/esp32-env/dht11)
LSP :: Error from the Language Server: not indexed (Invalid Request) [9 times]

And no syntax highlighting at all. Anyone know how to figure this out?


platform = espressif32
board = featheresp32
framework = arduino
lib_deps =
	adafruit/DHT sensor library@^1.4.4
	adafruit/Adafruit Unified Sensor@^1.1.7

EDIT: added platformio.ini, clarity

In the end an easy solution (that took a long time to figure out). Use .ccls instead of compiledb (making sure to delete compile_commands.json if it’s there), and then make sure platformio updates the .ccls file after installing new libraries by running pio project init -ide emacs.