Skip to content

motform/arduino-cli-mode

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

53 Commits
 
 
 
 
 
 

Repository files navigation

arduino-cli-mode

arduino-cli-mode is an Emacs minor mode for using the excellent new arduino command line interface in an Emacs-native fashion. The mode covers the full range of arduino-cli features in an Emacs native fashion. It even leverages the infinite power the GNU to provide fussy-finding of libraries and much improved support for handling multiple boards. The commands that originally require multiple steps (such as first searching for a library and then separately installing it) have been folded into one.

Installation

The recommended way to install arduino-cli-mode is through melpa. Depending on if you use arduino-mode or not, you might want to load arduino-cli-mode either as a hook or as a mode. A sample configuration with use-package could look like this:

(use-package arduino-cli-mode
  :ensure t
  ;; :hook arduino-mode
  ;; :mode "\\.ino\\'"
  :custom
  (arduino-cli-warnings 'all)
  (arduino-cli-verify t))

Default boards

By default arduino-cli-mode uses the board list command from arduino-cli to determine which board to target. This works well most of the time, but sometimes fails due to connectivity issues. It also requires the target board to be connected, which might not always be possible. To cover these use cases you are able to set a default board (fqbn) and port via arduino-cli-default-fqbn and arduino-cli-default-port respectively. These can of course be set global via your init, but have found them to be an excellent fit for dir and file local variables. To get the fqbn/port information for a currently connected board, use arduino-cli-board-list.

Using default board variables should be a bit faster, as it eliminates the need to shelling out and then parse JSON from arduino-cli.

Customization

You can enable the major flags from arduino-cli using similar enumerations.

Flag Values
arduino-cli-verify nil (default), t
arduino-cli-warnings nil (default), 'default, 'more, 'all
arduino-cli-verbosity nil (default), 'quiet, 'verbose
arduino-cli-compile-only-verbosity nil, t (default)

If you want to automatically enable arduino-cli-mode on .ino files, you have to get auto-minor-mode. Once that is installed, add the following to your init:

(add-to-list 'auto-minor-mode-alist '("\\.ino\\'" . arduino-cli-mode))

Keymap

The default keymap prefix is C-c C-a and can be customized with arduino-cli-mode-keymap-prefix.

The following keybindings are provided out of the box.

Function Keymap
Compile C-c C-a c
Upload C-c C-a u
Compile and Upload C-c C-a b
List Connected Boards C-c C-a l
Create new sketch C-c C-a n
Install a Library C-c C-a i
Uninstall a Library C-c C-a u
Kill Arduino Connection C-c C-a k

Limitations

  • Does not support board attach commands
  • Only tested on macOS (but will probably work on other Unices)
  • Not called elduino-mode

What it is not

This mode is not an Arduino major mode, it only provides convenient access to arduino-cli. If you are looking for something like that, check out arduino-mode. In fact, I think they would complement each other rather well, as arduino-mode lacks support for arduino-cli, simply due to pre-dating it with a decade.

If you want auto-completion for Arduino development, see company-arduino.

Depending on your board, you might also enjoy platform-io-mode, an excellent wrapper that I took a lot of inspiration from while writing this one.

Contribute

This is my first real elisp project, so everything from code review to feature implementations are welcome! The plan is to support (more or less) the entire feature set of arduino-cli, and then go into maintenance mode.

About

emacs support for the arduino-cli

Topics

Resources

License

Stars

Watchers

Forks

Contributors 4

  •  
  •  
  •  
  •