• Stars
    star
    345
  • Rank 122,750 (Top 3 %)
  • Language
    Vim Script
  • License
    MIT License
  • Created over 9 years ago
  • Updated 9 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Vim plugin for compiling and uploading arduino sketches

vim-arduino

Vim plugin for compiling, uploading, and debugging arduino sketches. It uses arduino-cli when available (recommended), and falls back to using the Arduino IDE's commandline interface (new in 1.5.x).

Installation

vim-arduino works with all the usual plugin managers

Packer (Neovim only)
require('packer').startup(function()
    use {'stevearc/vim-arduino'}
end)
Paq (Neovim only)
require "paq" {
    {'stevearc/vim-arduino'};
}
vim-plug
Plug 'stevearc/vim-arduino'
dein
call dein#add('stevearc/vim-arduino')
Pathogen
git clone --depth=1 https://github.com/stevearc/vim-arduino.git ~/.vim/bundle/
Neovim native package
git clone --depth=1 https://github.com/stevearc/vim-arduino.git \
  "${XDG_DATA_HOME:-$HOME/.local/share}"/nvim/site/pack/vim-arduino/start/vim-arduino
Vim8 native package
git clone --depth=1 https://github.com/stevearc/vim-arduino.git \
  "$HOME"/.vim/pack/vim-arduino/start/vim-arduino

Requirements

Linux and Mac are tested and functioning. I have not tested on Windows, but have heard that it works via WSL. See this issue for discussion.

It is recommended to use arduino-cli, installation instructions here: https://arduino.github.io/arduino-cli/latest/installation/

However it is also possible to use the arduino IDE directly. Download Arduino IDE (version 1.5 or newer). Linux users make sure the arduino command is in your PATH.

Commands

Command arg description
ArduinoAttach [port] Automatically attach to your board (see arduino-cli board attach -h)
ArduinoChooseBoard [board] Select the type of board. With no arg, will present a choice dialog.
ArduinoChooseProgrammer [programmer] Select the programmer. With no arg, will present a choice dialog.
ArduinoChoosePort [port] Select the serial port. With no arg, will present a choice dialog.
ArduinoVerify Build the sketch.
ArduinoUpload Build and upload the sketch.
ArduinoSerial Connect to the board for debugging over a serial port.
ArduinoUploadAndSerial Build, upload, and connect for debugging.
ArduinoInfo Display internal information. Useful for debugging issues with vim-arduino.

To make easy use of these, you may want to bind them to a key combination. You can put them in ftplugin/arduino.vim:

" Change these as desired
nnoremap <buffer> <leader>aa <cmd>ArduinoAttach<CR>
nnoremap <buffer> <leader>av <cmd>ArduinoVerify<CR>
nnoremap <buffer> <leader>au <cmd>ArduinoUpload<CR>
nnoremap <buffer> <leader>aus <cmd>ArduinoUploadAndSerial<CR>
nnoremap <buffer> <leader>as <cmd>ArduinoSerial<CR>
nnoremap <buffer> <leader>ab <cmd>ArduinoChooseBoard<CR>
nnoremap <buffer> <leader>ap <cmd>ArduinoChooseProgrammer<CR>

Configuration

By default you should not need to set any options for vim-arduino to work (especially if you're using arduino-cli, which tends to behave better). If you want to see what's available for customization, there is detailed information in the vim docs.

Integrations

Dialog / picker plugins

The built-in mechanism for choosing items (e.g. :ArduinoChooseBoard) uses inputlist() and is not very pretty or ergonomic. If you would like to improve the UI, there are two approaches:

  • Neovim: override vim.ui.select (e.g. by using a plugin like dressing.nvim)
  • Vim8: install ctrlp or fzf. They will automatically be detected and used

Tmux / screen

If you want to run the arduino commands in a separate tmux or screen pane, use vim-slime. By setting let g:arduino_use_slime = 1 vim-arduino will send the commands via slime#send() instead of running them inside a vim terminal.

Status Line

You may want to display the arduino state in your status line. There are four pieces of data you may find interesting:

  • g:arduino_board - the currently selected board
  • g:arduino_programmer - the currently selected programmer
  • g:arduino_serial_baud - the baud rate that will be used for Serial commands
  • arduino#GetPort() - returns the port that will be used for communication

An example with vanilla vim or nvim, added to ftplugin/arduino.vim:

" my_file.ino [arduino:avr:uno] [arduino:usbtinyisp] (/dev/ttyACM0:9600)
function! ArduinoStatusLine()
  let port = arduino#GetPort()
  let line = '[' . g:arduino_board . '] [' . g:arduino_programmer . ']'
  if !empty(port)
    let line = line . ' (' . port . ':' . g:arduino_serial_baud . ')'
  endif
  return line
endfunction
augroup ArduinoStatusLine
  autocmd! * <buffer>
  autocmd BufWinEnter <buffer> setlocal stl=%f\ %h%w%m%r\ %{ArduinoStatusLine()}\ %=\ %(%l,%c%V\ %=\ %P%)
augroup END

To do the same thing with vim-airline:

autocmd BufNewFile,BufRead *.ino let g:airline_section_x='%{MyStatusLine()}'

For lualine (Neovim only) I use the following function:

local function arduino_status()
  if vim.bo.filetype ~= "arduino" then
    return ""
  end
  local port = vim.fn["arduino#GetPort"]()
  local line = string.format("[%s]", vim.g.arduino_board)
  if vim.g.arduino_programmer ~= "" then
    line = line .. string.format(" [%s]", vim.g.arduino_programmer)
  end
  if port ~= 0 then
    line = line .. string.format(" (%s:%s)", port, vim.g.arduino_serial_baud)
  end
  return line
end

License

Everything is under the MIT License except for the wonderful syntax file, which was created by Johannes Hoff and copied from vim.org and is under the Vim License.

More Repositories

1

oil.nvim

Neovim file explorer: edit your filesystem like a buffer
Lua
3,907
star
2

conform.nvim

Lightweight yet powerful formatter plugin for Neovim
Lua
3,073
star
3

dressing.nvim

Neovim plugin to improve the default vim.ui interfaces
Lua
1,844
star
4

aerial.nvim

Neovim plugin for a code outline window
Lua
1,711
star
5

overseer.nvim

A task runner and job management plugin for Neovim
Lua
1,193
star
6

pypicloud

S3-backed pypi server implementation
Python
505
star
7

quicker.nvim

Improved UI and workflow for the Neovim quickfix
Lua
321
star
8

stickybuf.nvim

Neovim plugin for locking a buffer to a window
Lua
246
star
9

resession.nvim

A replacement for mksession with a better API
Lua
226
star
10

gkeep.nvim

Google Keep integration for Neovim
Python
193
star
11

dql

A SQL-ish language for DynamoDB
Python
149
star
12

flywheel

Object mapper for Amazon's DynamoDB
Python
128
star
13

profile.nvim

lua profiler for nvim
Lua
126
star
14

qf_helper.nvim

A collection of improvements for the quickfix buffer
Lua
97
star
15

pypicloud-docker

Docker image for pypicloud
Shell
86
star
16

dotfiles

Lua
57
star
17

godot_parser

Python library for parsing Godot scene files
Python
54
star
18

pair-ls

Editor-agnostic remote pair programming
TypeScript
28
star
19

three.nvim

Neovim plugin for working with buffers, windows, and tabs
Lua
21
star
20

nvim-typecheck-action

Github action for typechecking a neovim plugin
Lua
17
star
21

pair-ls.nvim

Neovim plugin for pair-ls
Lua
14
star
22

dynamo3

Python 3 compatible library for DynamoDB
Python
13
star
23

gitstack

A utility for stacking branches and github pull requests
Python
12
star
24

pyramid_webpack

Pyramid extension for managing assets with Webpack
Python
10
star
25

vim-vscode-snippets

A collection of vscode snippets for vim
Python
9
star
26

nvim_doc_tools

Python scripts for Neovim documentation generation
Python
7
star
27

pyramid_duh

Utilities that you'll want for nearly every pyramid app
Python
6
star
28

Battlecode-Server-Tester

Distributed testing tool for the MIT Battlecode competition
Java
3
star
29

parseargs

Bash utility for parsing commandline arguments
Shell
2
star
30

pike

Asset pipeline and make tool
Go
2
star
31

pair-ls-vscode

VS Code extension for pair-ls
TypeScript
2
star
32

eat_your_vegetables

An organizational wrapper around celery
Python
2
star
33

bluepill

A command line utility for working inside docker containers
Python
2
star
34

pore

Command line full-text search
Rust
2
star
35

flow-coverage.nvim

Neovim plugin to display flow type coverage information
Lua
2
star
36

stevearc

1
star
37

stevetags

Little website for tagging Dropbox files
Python
1
star