Plugins required:
https://www.github.com/neoclide/coc.nvim
https://www.github.com/neomake/neomake
https://www.github.com/w0rp/ale
First, create a Makefile file in the project directory
# Uncomment lines below if you have problems with $PATH
#SHELL := /bin/bash
#PATH := /usr/local/bin:$(PATH)
all:
platformio run
upload:
platformio run --target upload
clean:
platformio run --target clean
program:
platformio run --target program
uploadfs:
platformio run --target uploadfs
update:
platformio updateConfigure coc-vim to play nicely with clangd using :CocConfig
{
"languageserver": {
"clangd": {
"command": "clangd",
"args": ["--background-index"],
"rootPatterns": [
"compile_flags.txt",
"compile_commands.json",
".vim/",
".git/",
".hg/"
],
"filetypes": ["c", "cpp", "objc", "objcpp"]
}
},
"diagnostic.displayByAle": true
}Configure ALE to be nice with clangd in .vimrc
let g:ale_linters = { 'cpp': ['clangd'] }
let g:ale_fixers = { 'cpp': [ 'clang-format' ] }Generate compile_commands.json using Bear.
Since platformio takes care of compile flags, we need to feed clang with the correct flags for our project.
To do so, we need to create a file named compile_commands.json and place it in the project directory. This file includes all the information necessary for clang to be able to build this project. Creating this file automatically is possible using Bear.
make clean
bear make allOnce the file is generated, clangd could work on the project correctly.
It is important to recreate compile_commands.json each time the project structure changes, build flags changed, libraries added or removed.
To build the project in vim, simply call :Neomake! any compilation errors will appear in vim.

Hi Neta
you don't have problem libraries in vim?
in my vim not found Arduino.h and another external libraries but there are found in vs code!