normen / vim-pio

Vim Plugin for PlatformIO
48 stars 4 forks source link

Vim-PlatformIO

Introduction

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.

asciicast

Features

Installation

PlatformIO Core

Make sure you have the PlatformIO command line tools installed.

On MacOS with Homebrew installed just do:

brew install platformio

Plugin

With vim-plug installed, add this to your vimrc:

Plug 'normen/vim-pio'

Documentation

Use :h pio in vim for documentation of all commands and options.

Basic Commands

Makefile

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.

Other things

Code completion

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.

Hint

If Clangd can't pick up the correct folders for some reason, add this to your platformio.ini:

[default]
build_flags=-Isrc -Ilib

Background Make

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.

Further Info

This plugin is based on the built-in VIM and ccls support of PlatformIO, check out the information here