Skip to content

Commit 0d85f61

Browse files
committed
Add support for Arduino 1.5.x and common libraries
Fix #10
1 parent c3c2b1f commit 0d85f61

File tree

2 files changed

+178
-54
lines changed

2 files changed

+178
-54
lines changed

README.md

Lines changed: 41 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,62 @@
11
vim-arduino-syntax
2-
==================
2+
===================
33

44
Love Arduino and Vim? Then use this syntax file and get syntax highlighting for Arduino functions in vim.
55

6-
Installation
7-
============
6+
## Features
87

9-
Manual
10-
------
11-
- Copy `syntax/arduino.vim` file into your `~/.vim/syntax` directory
12-
- Copy `ftdetect/arduino.vim` file into your `~/.vim/ftdetect` directory
8+
- Supports both Arduino IDE 1.0.x and 1.5.x
9+
- Arduino indent and syntax highlighting
10+
- Support for libraries provided by the IDE
11+
- Autocompletion (using omnicomplete)
12+
13+
## TODO
14+
15+
- Automatically include keywords from keywords.txt of Arduino User libraries
16+
17+
## Installation
18+
19+
This plugin follows the standard runtime path structure, and as such it can be installed with a variety of plugin managers:
20+
21+
### [Pathogen](https://github.com/tpope/vim-pathogen)
22+
23+
```sh
24+
git clone https://github.com/sudar/vim-arduino-syntax
25+
```
1326

14-
Using [Vundle](https://github.com/gmarik/vundle)
15-
-------------
27+
Remember to run `:Helptags` to generate help tags
1628

17-
```VimL
29+
### [NeoBundle](https://github.com/Shougo/neobundle.vim)
1830

19-
Plugin 'sudar/vim-arduino-syntax'
31+
```
32+
NeoBundle 'vim-arduino-syntax'
33+
```
2034

21-
And :PluginInstall
35+
### [Vundle](https://github.com/gmarik/Vundle.vim)
2236

2337
```
24-
Credit
25-
======
38+
Plugin 'sudar/vim-arduino-syntax'
2639
27-
The syntax file was originally created by Johannes Hoff. I regenerated the file using his [python script](https://bitbucket.org/johannes/arduino-vim-syntax) and added some additional changes on top of it.
40+
:PluginInstall
41+
```
2842

29-
TODO
30-
====
43+
### Manual
3144

32-
- Create a separate branch for Arduino 1.5
33-
- Automatically include keywords from keywords.txt of Arduino libraries
45+
- Copy `syntax/arduino.vim` file into your `~/.vim/syntax` directory
46+
- Copy `ftdetect/arduino.vim` file into your `~/.vim/ftdetect` directory
47+
- Copy `indent/arduino.vim` file into your `~/.vim/indent` directory
3448

35-
Contributions
36-
================
49+
## Contributing
3750

3851
Contributions are always welcome in the form of pull requests with explanatory comments.
3952

40-
Other tools for Arduino and Vim
41-
===========================
53+
## Credit
54+
55+
- The syntax file was originally created by Johannes Hoff. I regenerated the file using his [python script](https://bitbucket.org/johannes/arduino-vim-syntax) and added some additional changes on top of it.
56+
- Arduino 1.5.x support was added by [z3t0](https://github.com/z3t0)
57+
- Support for indent was added by [KevinSjoberg](https://github.com/KevinSjoberg)
58+
59+
## Other tools for Arduino and Vim
4260

4361
If you are using Arduino with Vim, then also checkout some of my other projects.
4462

syntax/arduino.vim

Lines changed: 137 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,13 @@
22
" Language: Arduino
33
" Maintainer: Sudar <sudar@sudarmuthu.com>
44
" Original Author: Johannes Hoff <johannes@johanneshoff.com>
5-
" Last Change: 19 February 2013
5+
" Last Change: 27 April 2015
66
" License: VIM license (:help license, replace vim by arduino.vim)
77

88
" Syntax highlighting like in the Arduino IDE
9-
" Automatically generated by the script available at
10-
" https://bitbucket.org/johannes/arduino-vim-syntax
11-
" Using keywords from <arduino>/lib/keywords.txt
12-
" From version:
139

1410
" Thanks to original author Johannes Hoff and Rik, Erik Nomitch, Adam Obeng and Graeme Cross for helpful feedback!
11+
" Thanks to Rafi Khan for Arduino 1.5.x support
1512

1613
" For version 5.x: Clear all syntax items
1714
" For version 6.x: Quit when a syntax file was already loaded
@@ -28,33 +25,142 @@ else
2825
runtime! syntax/cpp.vim
2926
endif
3027

31-
syn keyword arduinoConstant BIN CHANGE DEC DEFAULT EXTERNAL FALLING HALF_PI HEX
32-
syn keyword arduinoConstant HIGH INPUT INPUT_PULLUP INTERNAL INTERNAL1V1
33-
syn keyword arduinoConstant INTERNAL2V56 LOW LSBFIRST MSBFIRST OCT OUTPUT PI
34-
syn keyword arduinoConstant RISING TWO_PI
35-
36-
syn keyword arduinoFunc analogRead analogReference analogWrite
37-
syn keyword arduinoFunc attachInterrupt bit bitClear bitRead bitSet
38-
syn keyword arduinoFunc bitWrite delay delayMicroseconds detachInterrupt
39-
syn keyword arduinoFunc digitalRead digitalWrite highByte interrupts
40-
syn keyword arduinoFunc lowByte micros millis noInterrupts noTone pinMode
41-
syn keyword arduinoFunc pulseIn shiftIn shiftOut tone
42-
43-
syn keyword arduinoMethod available begin end find findUntil flush loop
44-
syn keyword arduinoMethod parseFloat parseInt peek print println read
45-
syn keyword arduinoMethod readBytes readBytesUntil setTimeout setup
46-
47-
syn keyword arduinoModule Serial Serial1 Serial2 Serial3
48-
49-
syn keyword arduinoStdFunc abs acos asin atan atan2 ceil constrain cos degrees
50-
syn keyword arduinoStdFunc exp floor log map max min radians random randomSeed
51-
syn keyword arduinoStdFunc round sin sq sqrt tan
52-
53-
syn keyword arduinoType boolean byte null String word
28+
"C:/Program Files (x86)/Arduino\hardware\arduino\avr\libraries\EEPROM\keywords.txt{{{
29+
syn keyword arduinoConstant EEPROM
30+
"}}}
31+
"C:/Program Files (x86)/Arduino\hardware\arduino\avr\libraries\SoftwareSerial\keywords.txt{{{
32+
syn keyword arduinoFunc SoftwareSerial begin end read write available isListening overflow flush listen
33+
syn keyword arduinoFunc peek
34+
"}}}
35+
"C:/Program Files (x86)/Arduino\hardware\arduino\avr\libraries\SPI\keywords.txt{{{
36+
syn keyword arduinoConstant SPI SPI_CLOCK_DIV4 SPI_CLOCK_DIV16 SPI_CLOCK_DIV64 SPI_CLOCK_DIV128 SPI_CLOCK_DIV2 SPI_CLOCK_DIV8 SPI_CLOCK_DIV32 SPI_CLOCK_DIV64 SPI_MODE0
37+
syn keyword arduinoConstant SPI_MODE1 SPI_MODE2 SPI_MODE3
38+
syn keyword arduinoFunc begin end transfer setBitOrder setDataMode setClockDivider
39+
"}}}
40+
"C:/Program Files (x86)/Arduino\hardware\arduino\avr\libraries\Wire\keywords.txt{{{
41+
syn keyword arduinoFunc begin setClock beginTransmission endTransmission requestFrom send receive onReceive onRequest Wire
42+
"}}}
43+
"C:/Program Files (x86)/Arduino\hardware\arduino\sam\libraries\SPI\keywords.txt{{{
44+
syn keyword arduinoConstant SPI SPI_MODE0 SPI_MODE1 SPI_MODE2 SPI_MODE3 SPI_CONTINUE SPI_LAST
45+
syn keyword arduinoFunc begin end transfer setDataMode setClockDivider
46+
"}}}
47+
"C:/Program Files (x86)/Arduino\hardware\arduino\sam\libraries\Wire\keywords.txt{{{
48+
syn keyword arduinoFunc begin setClock beginTransmission endTransmission requestFrom send receive onReceive onRequest Wire
49+
syn keyword arduinoFunc Wire1
50+
"}}}
51+
"C:/Program Files (x86)/Arduino\lib\keywords.txt{{{
52+
syn keyword arduinoConstant HIGH LOW INPUT INPUT_PULLUP OUTPUT DEC BIN HEX OCT PI
53+
syn keyword arduinoConstant HALF_PI TWO_PI LSBFIRST MSBFIRST CHANGE FALLING RISING DEFAULT EXTERNAL INTERNAL
54+
syn keyword arduinoConstant INTERNAL1V1 INTERNAL2V56
55+
syn keyword arduinoType boolean break byte case char class const continue default do
56+
syn keyword arduinoType double else false float for if int long new null
57+
syn keyword arduinoType private protected public register return short signed static String switch
58+
syn keyword arduinoType this throw try true unsigned void while word boolean byte
59+
syn keyword arduinoType char float int long word
60+
syn keyword arduinoFunc abs acos asin atan atan2 ceil constrain cos degrees exp
61+
syn keyword arduinoFunc floor log map max min radians random randomSeed round sin
62+
syn keyword arduinoFunc sq sqrt tan pow bitRead bitWrite bitSet bitClear bit highByte
63+
syn keyword arduinoFunc lowByte analogReference analogRead analogWrite attachInterrupt detachInterrupt delay delayMicroseconds digitalWrite digitalRead
64+
syn keyword arduinoFunc interrupts millis micros noInterrupts noTone pinMode pulseIn shiftIn shiftOut tone
65+
syn keyword arduinoFunc yield
66+
syn keyword arduinoIdentifier Serial Serial1 Serial2 Serial3
67+
syn keyword arduinoFunc SerialUSB begin end peek read
68+
syn keyword arduinoFunc print println available availableForWrite flush setTimeout find findUntil parseInt parseFloat
69+
syn keyword arduinoFunc readBytes readBytesUntil readString readStringUntil trim toUpperCase toLowerCase charAt compareTo concat
70+
syn keyword arduinoFunc endsWith startsWith equals equalsIgnoreCase getBytes indexOf lastIndexOf length replace setCharAt
71+
syn keyword arduinoFunc substring toCharArray toInt Keyboard Mouse press release releaseAll accept click
72+
syn keyword arduinoFunc move isPressed setup loop
73+
"}}}
74+
"C:/Program Files (x86)/Arduino\libraries\Audio\keywords.txt{{{
75+
syn keyword arduinoFunc Audio prepare write
76+
"}}}
77+
"C:/Program Files (x86)/Arduino\libraries\Bridge\keywords.txt{{{
78+
syn keyword arduinoConstant FILE_READ FILE_WRITE FILE_APPEND
79+
syn keyword arduinoFunc Bridge FileIO FileSystem Console Process Mailbox HttpClient YunServer YunClient begin
80+
syn keyword arduinoFunc end available read peek write flush bool transfer put get
81+
syn keyword arduinoFunc buffer noBuffer connected File seek position size close name isDirectory
82+
syn keyword arduinoFunc openNextFile rewindDirectory addParameter runAsynchronously run running exitValue runShellCommand runShellCommandAsynchronously readMessage
83+
syn keyword arduinoFunc writeMessage writeJSON message Available getAsynchronously ready getResult accept stop connect connected
84+
"}}}
85+
"C:/Program Files (x86)/Arduino\libraries\Esplora\keywords.txt{{{
86+
syn keyword arduinoConstant JOYSTICK_BASE MAX_CHANNELS CH_SWITCH_1 CH_SWITCH_2 CH_SWITCH_3 CH_SWITCH_4 CH_SLIDER CH_LIGHT CH_TEMPERATURE CH_MIC
87+
syn keyword arduinoConstant CH_JOYSTICK_SW CH_JOYSTICK_X CH_JOYSTICK_Y SWITCH_1 SWITCH_2 SWITCH_3 SWITCH_4 SWITCH_DOWN SWITCH_LEFT SWITCH_UP
88+
syn keyword arduinoConstant SWITCH_RIGHT JOYSTICK_DOWN JOYSTICK_LEFT JOYSTICK_UP PRESSED RELEASED DEGREES_C DEGREES_F X_AXIS Y_AXIS
89+
syn keyword arduinoConstant Z_AXIS
90+
syn keyword arduinoFunc Esplora begin readSlider readLightSensor readTemperature readMicrophone readJoystickSwitch readJoystickButton readJoystickX readJoystickY
91+
syn keyword arduinoFunc readAccelerometer readButton writeRGB writeRed writeGreen writeBlue readRed readGreen readBlue readBlue
92+
syn keyword arduinoFunc readBlue readBlue tone noTone
93+
"}}}
94+
"C:/Program Files (x86)/Arduino\libraries\Ethernet\keywords.txt{{{
95+
syn keyword arduinoFunc Ethernet EthernetClient EthernetServer IPAddress status connect write available read peek
96+
syn keyword arduinoFunc flush stop connected begin beginPacket endPacket parsePacket remoteIP remotePort
97+
"}}}
98+
"C:/Program Files (x86)/Arduino\libraries\Firmata\keywords.txt{{{
99+
syn keyword arduinoConstant MAX_DATA_BYTES DIGITAL_MESSAGE ANALOG_MESSAGE REPORT_ANALOG REPORT_DIGITAL REPORT_VERSION SET_PIN_MODE SYSTEM_RESET START_SYSEX END_SYSEX
100+
syn keyword arduinoConstant PWM TOTAL_ANALOG_PINS TOTAL_DIGITAL_PINS TOTAL_PORTS ANALOG_PORT
101+
syn keyword arduinoFunc Firmata callbackFunction systemResetCallbackFunction stringCallbackFunction sysexCallbackFunction begin begin printVersion blinkVersion printFirmwareVersion
102+
syn keyword arduinoFunc setFirmwareVersion setFirmwareNameAndVersion available processInput sendAnalog sendDigital sendDigitalPortPair sendDigitalPort sendString sendString
103+
syn keyword arduinoFunc sendSysex attach detach flush
104+
"}}}
105+
"C:/Program Files (x86)/Arduino\libraries\GSM\keywords.txt{{{
106+
syn keyword arduinoConstant GSM GSM_SMS GPRS GSMPIN GSMPIN ERROR IDLE CONNECTING GSM_READY GPRS_READY
107+
syn keyword arduinoConstant TRANSPARENT_CONNECTED IDLE_CALL CALLING RECEIVINGCALL TALKING GSM_MODE_UNDEFINED GSM_MODE_EGSM GSM_MODE_DCS GSM_MODE_PCS GSM_MODE_EGSM_DCS
108+
syn keyword arduinoConstant GSM_MODE_GSM850_PCS GSM_MODE_GSM850_EGSM_DCS_PCS
109+
syn keyword arduinoFunc GSMVoiceCall GSMClient GSMServer GSMModem GSMScanner begin shutdown gatVoiceCallStatus ready voiceCall
110+
syn keyword arduinoFunc answerCall hangCall retrieveCallingNumber beginSMS endSMS remoteNumber attachGPRS begnWrite endWrite getIMEI
111+
syn keyword arduinoFunc getCurrentCarrier getSignalStrength readNetworks isPIN checkPIN checkPUK changePIN switchPIN checkReg getPINUsed
112+
syn keyword arduinoFunc setPINUsed getBand setBand getvoiceCallStatus
113+
"}}}
114+
"C:/Program Files (x86)/Arduino\libraries\LiquidCrystal\keywords.txt{{{
115+
syn keyword arduinoFunc LiquidCrystal begin clear home print setCursor cursor noCursor blink noBlink
116+
syn keyword arduinoFunc display noDisplay autoscroll noAutoscroll leftToRight rightToLeft scrollDisplayLeft scrollDisplayRight createChar setRowOffsets
117+
"}}}
118+
"C:/Program Files (x86)/Arduino\libraries\Scheduler\keywords.txt{{{
119+
syn keyword arduinoFunc Scheduler startLoop
120+
"}}}
121+
"C:/Program Files (x86)/Arduino\libraries\SD\keywords.txt{{{
122+
syn keyword arduinoConstant SD FILE_READ FILE_WRITE
123+
syn keyword arduinoFunc File begin exists mkdir remove rmdir open close seek position
124+
syn keyword arduinoFunc size
125+
"}}}
126+
"C:/Program Files (x86)/Arduino\libraries\Servo\keywords.txt{{{
127+
syn keyword arduinoFunc Servo attach detach write read attached writeMicroseconds readMicroseconds
128+
"}}}
129+
"C:/Program Files (x86)/Arduino\libraries\SpacebrewYun\keywords.txt{{{
130+
syn keyword arduinoFunc SpacebrewYun addPublish addSubscribe connect verbose monitor onMessage send onRangeMessage onStringMessage
131+
syn keyword arduinoFunc onBooleanMessage onCustomMessage onOpen onClose onError
132+
"}}}
133+
"C:/Program Files (x86)/Arduino\libraries\Stepper\keywords.txt{{{
134+
syn keyword arduinoFunc Stepper step setSpeed version direction speed
135+
"}}}
136+
"C:/Program Files (x86)/Arduino\libraries\Temboo\keywords.txt{{{
137+
syn keyword arduinoFunc Temboo TembooChoreo begin setAccountName setAppKeyName setAppKey setChoreo setCredential setSavedInputs addInput
138+
syn keyword arduinoFunc addOutputFilter setSettingsFileToWrite setSettingsFileToRead
139+
"}}}
140+
"C:/Program Files (x86)/Arduino\libraries\TFT\keywords.txt{{{
141+
syn keyword arduinoConstant TFT
142+
syn keyword arduinoFunc EsploraTFT
143+
"}}}
144+
"C:/Program Files (x86)/Arduino\libraries\TFT\src\utility\keywords.txt{{{
145+
syn keyword arduinoFunc Adafruit_GFX Adafruit_ST7735 PImage drawPixel invertDisplay drawLine drawFastVLine drawFastHLine drawRect fillRect
146+
syn keyword arduinoFunc fillScreen drawCircle drawCircleHelper fillCircle fillCircleHelper drawTriangle fillTriangle drawRoundRect fillRoundRect drawBitmap
147+
syn keyword arduinoFunc drawChar setCursor setTextColor setTextSize setTextWrap height width setRotation getRotation newColor
148+
syn keyword arduinoFunc background fill noFill stroke noStroke text textWrap textSize circle point
149+
syn keyword arduinoFunc quad rect triangle loadImage image draw isValid
150+
"}}}
151+
"C:/Program Files (x86)/Arduino\libraries\USBHost\keywords.txt{{{
152+
syn keyword arduinoFunc MouseController USBHost KeyboardController Task mouseMoved mouseDragged mousePressed mouseReleased getXChange getYChange
153+
syn keyword arduinoFunc getButton keyPressed keyReleased getModifiers getKey getOemKey
154+
"}}}
155+
"C:/Program Files (x86)/Arduino\libraries\WiFi\keywords.txt{{{
156+
syn keyword arduinoConstant SSID BSSID RSSI
157+
syn keyword arduinoFunc WiFi WiFiUdp Client Server firmwareVersion status connect write available config
158+
syn keyword arduinoFunc setDNS read flush stop connected begin disconnect macAddress localIP subnetMask
159+
syn keyword arduinoFunSec gatewayIP encryptionType getResult getSocket WiFiClient WiFiServer WiFiUDP beginPacket endPacket parsePacket
160+
syn keyword arduinoFunc remoteIP remotePort
161+
"}}}
54162

55163
hi def link arduinoType Type
56164
hi def link arduinoConstant Constant
57-
hi def link arduinoStdFunc Function
58165
hi def link arduinoFunc Function
59-
hi def link arduinoMethod Function
60-
hi def link arduinoModule Identifier
166+
hi def link arduinoIdentifier Identifier

0 commit comments

Comments
 (0)