I’m trying to set up clangd for an Arduino project on Windows, but I’m running into some issues and could use some help.
Context:
I’m trying working with Arduino sketches in Neovim and would like to use clangd to get better linting and Diagnostics support. However for some reason autocompletion works but my Diagnostics say: Use of undeclared identifier 'Serial' right next to both Serial in my Code below.
I compiled it using arduino-cli compile --fqbn arduino:esp32:nano_nora --build-path ./build .\test.ino then afterwards i copied the compile_commands.json and build.options.json to the root of my project.
The issue with Serial disappears when putting in #include "USBCDC.h" . But then i am getting this error: In included file: '../hal.h' file not found. I am also getting the same error when using #include "Arduino.h"
I already tried using the arduino-language-server but it seems not to work with Neovim currently I also tried downgrading my Neovim version without any achievements.
I’d appreciate any advice or tips,
Thanks in advance.
Which version of Arduino CLI do you have installed? The recent reports of problems using Arduino Language Server are usually found to be caused by people using the release version of Arduino language server with Arduino CLI >=1.0.0. There was a breaking change in the Arduino CLI API introduced in the 1.0.0 release which caused it to become incompatible with Arduino Language Server.
The compatibility has already been restored:
However, there hasn't been a new release of Arduino Language Server since that time so the release version can't be used with the latest Arduino CLI.