├── .gitignore ├── LICENSE ├── README.md ├── doc └── vim-arduino.txt └── plugin ├── vim-arduino-serial ├── vim-arduino-serial-iterm └── vim-arduino.vim /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2013 Jon Plaut 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Vim Arduino Ino 2 | 3 | ## UPDATE: THIS PROJECT IS DEPRECATED 4 | ### As of now, the Arduino Ino command line tool [does not work](https://github.com/amperka/ino/issues/71) with newer versions of the Arduino app. Thus, this tool will not work unless you install an older version of the Arduino app. If someone wants to contribute an update to Ino that supports newer versions of the app, they can submit a pull request to the [current repo](https://github.com/scottdarch/Arturo). 5 | 6 | This script is based on [Vim Arduino][vim-arduino], but uses the 7 | [Ino][ino] command line utility instead of the Java Arduino compiler. 8 | It therefore runs in 64-bit environments and allows for compiling and 9 | deployment of Arduino (\*.pde/\*.ino) sketches directly from Vim. 10 | 11 | ## Install 12 | 13 | The plugin is structured for use with [Pathogen][pathogen] so installation 14 | should be easy, assuming you have Pathogen installed. 15 | 16 | ## Requirements 17 | [Ano][ano] must be installed on your computer for this plugin to work (Previously, Ino was used, but that repo is no longer maintained). 18 | To install Ano, you can install from source using the instructions [here][ano] or ```npm install ano``` if you have npm installed. 19 | 20 | If you plan on using this plugin with a board other than an Arduino 21 | Uno, you'll need to configure Ino to use that board by following 22 | the instructions found [here][ino-config]. 23 | 24 | ## Usage 25 | Vim Arduino Ino can be run using the following keys: 26 | 27 | `ac` - Compile the current sketch. 28 | 29 | `ad` - Compile and deploy the current sketch. 30 | 31 | `as` - Open a serial port in `screen`. 32 | 33 | In order for the build to complete successfully, your project directory will need to be set up like a normal ino project. For more information on ino project setup, see [here][ino-project]. 34 | 35 | 36 | ## Options 37 | The default key mapping can be turned off by doing this in your `.vimrc`: 38 | 39 | ``` 40 | let g:vim_arduino_map_keys = 0 41 | ``` 42 | 43 | To open the serial monitor automatically after each deploy, 44 | add this to your `.vimrc`: 45 | 46 | ``` 47 | let g:vim_arduino_auto_open_serial = 1 48 | ``` 49 | 50 | To change the command used to build and deploy : 51 | 52 | ``` 53 | let g:vim_arduino_ino_cmd = 'ano' 54 | ``` 55 | 56 | 57 | [ino-config]: http://inotool.org/quickstart#configuration-files 58 | [pathogen]: http://www.vim.org/scripts/script.php?script_id=2332 59 | [ano]: https://github.com/scottdarch/Arturo 60 | [vim-arduino]: https://github.com/tclem/vim-arduino 61 | [arduino]: http://arduino.cc/en/Main/Software 62 | [ino-project]: http://inotool.org/quickstart 63 | -------------------------------------------------------------------------------- /doc/vim-arduino.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jplaut/vim-arduino-ino/7f545bca26d4b1f10ac5c9155f1243c61d15e342/doc/vim-arduino.txt -------------------------------------------------------------------------------- /plugin/vim-arduino-serial: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | echo "use Ctrl-a, k to exit the screen utility" 4 | 5 | port=$(ls /dev/tty.* | grep usb) 6 | 7 | osascript -e \ 8 | "tell application \"Terminal\" 9 | activate 10 | 11 | -- search all windows for the arduino-serial tab 12 | set winlist to every window 13 | local arduinoTab 14 | repeat with win in winlist 15 | set tablist to every tab of win 16 | repeat with currentTab in tablist 17 | set title to get custom title of currentTab 18 | if title is equal to \"arduino-serial\" then 19 | set arduinoTab to currentTab 20 | set frontmost of win to true 21 | end if 22 | end repeat 23 | end repeat 24 | 25 | -- make new tab when arduino-serial does not exist 26 | try 27 | arduinoTab 28 | on error 29 | tell application \"System Events\" 30 | set frontmost of application process \"Terminal\" to true 31 | keystroke \"t\" using command down 32 | end tell 33 | set currentTabIndex to (get count of tabs of front window) 34 | set arduinoTab to (tab currentTabIndex of front window) 35 | set custom title of arduinoTab to \"arduino-serial\" 36 | end try 37 | 38 | tell front window 39 | do script \"screen -S arduino-serial $port\" in arduinoTab 40 | end tell 41 | end tell" 42 | -------------------------------------------------------------------------------- /plugin/vim-arduino-serial-iterm: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | port=$(ls /dev/tty.* | grep usb) 4 | 5 | osascript -e \ 6 | " 7 | tell application \"iTerm2-.9\" 8 | tell current session of current window 9 | set newTab to (split horizontally with default profile) 10 | select newTab 11 | tell newTab 12 | write text \"screen -S arduino-serial $port\" 13 | end tell 14 | end tell 15 | end tell 16 | " 17 | -------------------------------------------------------------------------------- /plugin/vim-arduino.vim: -------------------------------------------------------------------------------- 1 | let s:vim_arduino_version = '0.1.0' 2 | 3 | " Load Once: {{{1 4 | if exists("loaded_vim_arduino") 5 | finish 6 | endif 7 | let loaded_vim_arduino = 1 8 | 9 | if !exists('g:vim_arduino_auto_open_serial') 10 | let g:vim_arduino_auto_open_serial = 0 11 | endif 12 | 13 | if !exists('g:vim_arduino_ino_cmd') 14 | let g:vim_arduino_ino_cmd = 'ino' 15 | endif 16 | 17 | if !exists('g:vim_arduino_serial_terminal_script') 18 | let g:vim_arduino_serial_terminal_script = 'vim-arduino-serial' 19 | endif 20 | 21 | let s:helper_dir = expand(":h") 22 | 23 | function! s:PrintStatus(result) 24 | if a:result == 0 25 | echohl Statement | echomsg "Succeeded." | echohl None 26 | else 27 | echohl WarningMsg | echomsg "Failed." | echohl None 28 | endif 29 | endfunction 30 | 31 | " Private: Compile or deploy code 32 | " 33 | " Returns nothing. 34 | function! s:InvokeArduinoCli(deploy) 35 | call s:ArduinoKillMonitor() 36 | let l:flag = a:deploy ? "-d" : "-c" 37 | let l:f_name = expand('%:p') 38 | execute "w" 39 | if a:deploy 40 | echomsg "Compiling and deploying..." l:f_name 41 | let l:result = system(g:vim_arduino_ino_cmd . " build && " . g:vim_arduino_ino_cmd . " upload") 42 | else 43 | echomsg "Compiling..." l:f_name 44 | let l:result = system(g:vim_arduino_ino_cmd . " build") 45 | endif 46 | 47 | echo l:result 48 | call s:PrintStatus(v:shell_error) 49 | 50 | return !v:shell_error 51 | endfunction 52 | 53 | " Private: Release the /dev/tty.usb* port so we can recompile 54 | " 55 | " Returns nothing. 56 | function! s:ArduinoKillMonitor() 57 | let output = system("screen -X -S" . g:vim_arduino_serial_terminal_script . "quit") 58 | endfunction 59 | 60 | " Public: Compile the current pde file. 61 | " 62 | " Returns nothing. 63 | function! ArduinoCompile() 64 | call s:InvokeArduinoCli(0) 65 | endfunction 66 | 67 | " Public: Compile and Deploy the current pde file. 68 | " 69 | " Returns nothing. 70 | function! ArduinoDeploy() 71 | call s:InvokeArduinoCli(1) 72 | 73 | " optionally auto open a serial port 74 | if g:vim_arduino_auto_open_serial 75 | call ArduinoSerialMonitor() 76 | endif 77 | endfunction 78 | 79 | " Public: Monitor a serial port 80 | " 81 | " Returns nothing. 82 | function! ArduinoSerialMonitor() 83 | echo system(s:helper_dir."/".g:vim_arduino_serial_terminal_script) 84 | endfunction 85 | 86 | if !exists('g:vim_arduino_map_keys') 87 | let g:vim_arduino_map_keys = 1 88 | endif 89 | 90 | if g:vim_arduino_map_keys 91 | nnoremap ac :call ArduinoCompile() 92 | nnoremap ad :call ArduinoDeploy() 93 | nnoremap as :call ArduinoSerialMonitor() 94 | endif 95 | --------------------------------------------------------------------------------