PlatformIO Vim Intellisense

Hello,

I use Neovim as my development IDE and have been experiencing an intellisense error when using #include <Arduino.h> indicating that the file cannot be found.

Granted this error is incorrect as I can run all my target commands, upload code, etc.

Do I need to include a file within my PATH, or something else entirely?

Any information or guidance is greatly appreciated.

Does Neovim have any plugins that support Compilation database compile_commands.json — PlatformIO latest documentation ?

See also Vim — PlatformIO latest documentation

There are plenty to choose from. Currently I am using coc.nvim for all LSPs.

I do use the CLI command pio project init --board <board> --ide vim when creating projects.

As I mentioned above, everything works and compiles fine. There is some light intellisense in regards to pin macros, some functions, etc. But, for instance, Serial is one that recieves no intellisense “support”.

I know that has been a few weeks since this post was written, and, after some investigating, it turns out that it’s not that the <Arduino.h> header file cannot be found with intellisense. It’s within <Arduino.h> that the <avr/pgmspace.h>, the library used to interface with the ATmega family, cannot be found. This would be a separate issue, but, I have found the source.

Thank you to all who helped with this issue!

Then the plugin is not using the right compiler (avr-gcc) and its include paths / files. Are you sure the compile_commands.json has the info on the full compiler path? If not, check out Compilation database compile_commands.json — PlatformIO latest documentation

The compile_commands.json file seems to have the correct compile path /Users/<username>/.platformio/packages/toolchain-atmelavr/bin/avr-gcc along with the compile flags for the various files (HardwareSerial, CDC, Wiring, etc.).

I would say that you’re right in that the ccls plugin is not using avr-gcc compiler. Would it be as simple as adding something like %avr-gcc <flags> within my .ccls file?

1 Like

ive made this gist explaining how to set it up for Neovim

1 Like