This is a collection of helper commands for VIM to ease the use of PlatformIO with VIM.
Its very much a WIP, its literally just parts of my vimrc outsourced into a plugin.
Make sure you have the PlatformIO command line tools installed.
On MacOS with Homebrew installed just do:
brew install platformio
With vim-plug installed, add this to your vimrc
:
Plug 'normen/vim-pio'
Use :h pio
in vim for documentation of all commands and options.
:PIO
:PIOInit <boardname>
:PIOInstall <libraryname>
:PIOUninstall <libraryname>
:PIONewProject <search>
:PIOAddLibrary <search>
:PIORemoveLibrary
The plugin creates a Makefile
, this way you can use a simple :make
to compile or a :make upload
to compile and upload your code to your microcontroller.
To have code completion in vim you'll need the Clangd or CCLS language server installed as well as a plugin for vim to use it.
Example LSP plugins for vim:
Please refer to the documentation of the LSP plugins for how to set them up.
vim-pio
uses PlatformIOs built-in functions to create .ccls
and compile-commands.json
files which can be picked up by CCLS and Clangd respectively.
If Clangd can't pick up the correct folders for some reason, add this to your platformio.ini
:
[default]
build_flags=-Isrc -Ilib
I suggest also installing the awesome vim-dispatch plugin by tpope to be able to use :Make
instead of :make
to run compilations in the background.
This plugin is based on the built-in VIM and ccls support of PlatformIO, check out the information here