├── ftdetect └── arduino.vim ├── indent └── arduino.vim ├── README.md └── syntax └── arduino.vim /ftdetect/arduino.vim: -------------------------------------------------------------------------------- 1 | au BufRead,BufNewFile *.ino,*.pde set filetype=arduino 2 | -------------------------------------------------------------------------------- /indent/arduino.vim: -------------------------------------------------------------------------------- 1 | " Vim indent file 2 | " Language: Arduino 3 | " Maintainer: Kevin Sjöberg 4 | " Last Change: 2014 Feb 28 5 | 6 | " Only load this indent file when no other was loaded. 7 | if exists("b:did_indent") 8 | finish 9 | endif 10 | let b:did_indent = 1 11 | 12 | " C++ indenting is built-in, thus this is very simple 13 | setlocal cindent 14 | 15 | let b:undo_indent = "setl cin<" 16 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | vim-arduino-syntax 2 | =================== 3 | 4 | Love Arduino and Vim? Then use this syntax file and get syntax highlighting for Arduino functions in vim. 5 | 6 | This plugin contributes to [vim-polyglot](https://github.com/sheerun/vim-polyglot) language pack. 7 | 8 | ## Features 9 | 10 | - Supports both Arduino IDE 1.0.x and 1.5.x 11 | - Arduino indent and syntax highlighting 12 | - Support for libraries provided by the IDE 13 | - Autocompletion (using omnicomplete) 14 | 15 | ## TODO 16 | 17 | - Automatically include keywords from keywords.txt of Arduino User libraries 18 | 19 | ## Installation 20 | 21 | This plugin follows the standard runtime path structure, and as such it can be installed with a variety of plugin managers: 22 | 23 | ### [Pathogen](https://github.com/tpope/vim-pathogen) 24 | 25 | ```sh 26 | git clone https://github.com/sudar/vim-arduino-syntax 27 | ``` 28 | 29 | Remember to run `:Helptags` to generate help tags 30 | 31 | ### [NeoBundle](https://github.com/Shougo/neobundle.vim) 32 | 33 | ``` 34 | NeoBundle 'vim-arduino-syntax' 35 | ``` 36 | 37 | ### [Vundle](https://github.com/gmarik/Vundle.vim) 38 | 39 | ``` 40 | Plugin 'sudar/vim-arduino-syntax' 41 | 42 | :PluginInstall 43 | ``` 44 | 45 | ### Manual 46 | 47 | - Copy `syntax/arduino.vim` file into your `~/.vim/syntax` directory 48 | - Copy `ftdetect/arduino.vim` file into your `~/.vim/ftdetect` directory 49 | - Copy `indent/arduino.vim` file into your `~/.vim/indent` directory 50 | 51 | ## Contributing 52 | 53 | Contributions are always welcome in the form of pull requests with explanatory comments. 54 | 55 | ## Credit 56 | 57 | - 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. 58 | - Arduino 1.5.x support was added by [z3t0](https://github.com/z3t0) 59 | - Support for indent was added by [KevinSjoberg](https://github.com/KevinSjoberg) 60 | 61 | ## Other tools for Arduino and Vim 62 | 63 | If you are using Arduino with Vim, then also checkout some of my other projects. 64 | 65 | - [Arduino snippets for Vim](https://github.com/sudar/vim-arduino-snippets) 66 | - [Arduino Make file](https://github.com/sudar/Arduino-Makefile) 67 | -------------------------------------------------------------------------------- /syntax/arduino.vim: -------------------------------------------------------------------------------- 1 | " Vim syntax file 2 | " Language: Arduino 3 | " Maintainer: Sudar 4 | " Original Author: Johannes Hoff 5 | " Last Change: 27 April 2015 6 | " License: VIM license (:help license, replace vim by arduino.vim) 7 | 8 | " Syntax highlighting like in the Arduino IDE 9 | 10 | " 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 12 | 13 | " For version 5.x: Clear all syntax items 14 | " For version 6.x: Quit when a syntax file was already loaded 15 | if version < 600 16 | syntax clear 17 | elseif exists("b:current_syntax") 18 | finish 19 | endif 20 | 21 | " Read the C syntax to start with 22 | if version < 600 23 | so :p:h/cpp.vim 24 | else 25 | runtime! syntax/cpp.vim 26 | endif 27 | 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 INPUT_PULLDOWN 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 | "}}} 162 | 163 | hi def link arduinoType Type 164 | hi def link arduinoConstant Constant 165 | hi def link arduinoFunc Function 166 | hi def link arduinoIdentifier Identifier 167 | --------------------------------------------------------------------------------