Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/stevearc/vim-arduino
Vim plugin for compiling and uploading arduino sketches
https://github.com/stevearc/vim-arduino
arduino-ide vim vim-arduino vim-plugin vim-plugins
Last synced: 5 days ago
JSON representation
Vim plugin for compiling and uploading arduino sketches
- Host: GitHub
- URL: https://github.com/stevearc/vim-arduino
- Owner: stevearc
- License: mit
- Created: 2015-06-30T05:01:44.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2024-02-10T02:33:29.000Z (12 months ago)
- Last Synced: 2025-01-21T03:07:42.113Z (13 days ago)
- Topics: arduino-ide, vim, vim-arduino, vim-plugin, vim-plugins
- Language: Vim Script
- Homepage:
- Size: 105 KB
- Stars: 353
- Watchers: 10
- Forks: 24
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# vim-arduino
Vim plugin for compiling, uploading, and debugging arduino sketches. It uses
[arduino-cli](https://arduino.github.io/arduino-cli/latest/) when available
(recommended), and falls back to using the Arduino IDE's [commandline
interface](https://github.com/arduino/Arduino/blob/master/build/shared/manpage.adoc)
(new in 1.5.x).## Installation
vim-arduino works with all the usual plugin managers
Packer (Neovim only)
```lua
require('packer').startup(function()
use {'stevearc/vim-arduino'}
end)
```Paq (Neovim only)
```lua
require "paq" {
{'stevearc/vim-arduino'};
}
```vim-plug
```vim
Plug 'stevearc/vim-arduino'
```dein
```vim
call dein#add('stevearc/vim-arduino')
```Pathogen
```sh
git clone --depth=1 https://github.com/stevearc/vim-arduino.git ~/.vim/bundle/
```Neovim native package
```sh
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
```sh
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](https://github.com/stevearc/vim-arduino/issues/4) 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](https://www.arduino.cc/en/Main/Software) (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`:```vim
" Change these as desired
nnoremap aa ArduinoAttach
nnoremap av ArduinoVerify
nnoremap au ArduinoUpload
nnoremap aus ArduinoUploadAndSerial
nnoremap as ArduinoSerial
nnoremap ab ArduinoChooseBoard
nnoremap ap ArduinoChooseProgrammer
```## 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](https://github.com/stevearc/vim-arduino/blob/master/doc/arduino.txt).## 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](https://github.com/stevearc/dressing.nvim))
- **Vim8:** install [ctrlp](https://github.com/ctrlpvim/ctrlp.vim) or [fzf](https://github.com/junegunn/fzf.vim). 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](https://github.com/jpalardy/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 communicationAn example with vanilla vim or nvim, added to `ftplugin/arduino.vim`:
```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! *
autocmd BufWinEnter setlocal stl=%f\ %h%w%m%r\ %{ArduinoStatusLine()}\ %=\ %(%l,%c%V\ %=\ %P%)
augroup END
```To do the same thing with [vim-airline](https://github.com/vim-airline/vim-airline):
```vim
autocmd BufNewFile,BufRead *.ino let g:airline_section_x='%{MyStatusLine()}'
```For [lualine](https://github.com/nvim-lualine/lualine.nvim) (Neovim only) I use
the following function:```lua
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](https://github.com/stevearc/vim-arduino/blob/master/LICENSE) except for
the wonderful syntax file, which was created by Johannes Hoff and copied from
[vim.org](http://www.vim.org/scripts/script.php?script_id=2654) and is under the
[Vim License](http://vimdoc.sourceforge.net/htmldoc/uganda.html).