Skip to content

Arduino

Yuta Yamada edited this page Jun 11, 2015 · 3 revisions

What is this page?

This page gives you how to use irony-mode on arduino-mode.

Prerequisite

You need to prepare irony-mode and arduino-mode. You can see the instruction here to install irony-mode.

arduino-mode can install both MELPA and el-get.

Using MELPA: M-x package-install RET arduino-mode RET
Using el-get: M-x el-get-install RET arduino-mode RET

Emacs configuration

Put below configuration to your .emacs or somewhere:

(add-to-list 'irony-supported-major-modes 'arduino-mode)
(add-to-list 'irony-lang-compile-option-alist '(arduino-mode . "c++"))

;; Turn-on irony-mode on arduino-mode (on .ino file).
(add-hook 'arduino-mode-hook 'irony-mode)

and then make .clang_complete file to your arduino development directory to allow Arduino's include path directory. On Linux, Arduino IDE's default sketch directory is ~/Arduino, so maybe ~/Arduino/.clang_complete is better place if you don't decide it yet.

Below text is the content of .clang_complete, but please change the path to your Arduino IDE's path. (On windows, you need use \ instead of /)

-I/home/username/path/to/your/arduino-1.6.3/hardware/arduino/avr/cores/arduino/
-I/home/username/path/to/your/arduino-1.6.3/hardware/tools/avr/include/
-I/home/username/path/to/your/arduino-1.6.3/hardware/arduino/avr/libraries/
-include
/home/username/path/to/your/arduino-1.6.3/hardware/arduino/avr/cores/arduino/Arduino.h

That's it!

After reboot your Emacs, you will see irony-mode's auto-complete function on arduino-mode.

C/C++ related package

irony-eldoc : eldoc support for irony-mode
company-c-headers : auto-complete support for header files
cpp-auto-include : insert include directive automatically

Clone this wiki locally