Skip to content

Commit 765d612

Browse files
committed
Allow overriding sketchbook and Arduino library paths.
1 parent e9977eb commit 765d612

File tree

2 files changed

+25
-6
lines changed

2 files changed

+25
-6
lines changed

plugin/vim-arduino

+14-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/bin/sh
2-
#/ Usage: vim-arduino <pde file> [board] [serialport]
2+
#/ Usage: vim-arduino <pde file> [board] [serialport] [sketchbook] [arduinohome]
33
#/ Invokes the Arduino IDE command line runner to compile and deploy
44
#/ Arduino sketches.
55
#/
@@ -13,6 +13,8 @@
1313
pde_file=
1414
board="uno"
1515
port=
16+
sketchbook=
17+
arduinohome=
1618
switch="-c"
1719

1820
while [ $# -gt 0 ]
@@ -36,6 +38,16 @@ do
3638
switch="-c"
3739
shift
3840
;;
41+
-k|--sketchbook)
42+
shift
43+
sketchbook=$1
44+
shift
45+
;;
46+
-a|--arduinohome)
47+
shift
48+
arduinohome=$1
49+
shift
50+
;;
3951
*)
4052
if [ -z "$pde_file" ]
4153
then pde_file="$1"
@@ -75,12 +87,9 @@ fi
7587

7688
# echo "Compiling '$pde_file' for board $board on serial port $port"
7789

78-
sketchbook=$(echo $HOME/Documents/Arduino)
79-
8090
DIR="$( cd "$( dirname "$0" )" && pwd )"
8191
java \
82-
-Djava.library.path=/Applications/Arduino.app/Contents/Resources/Java \
83-
-d32 \
92+
-Djava.library.path="$arduinohome" \
8493
-Darduino.sketchbook="$sketchbook" \
8594
-Djava.awt.headless=true \
8695
-jar "$DIR/vim-arduino-cli.jar" "$switch" "$pde_file" "$port" "$board"

plugin/vim-arduino.vim

+11-1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,14 @@ if !exists('g:vim_arduino_auto_open_serial')
4444
let g:vim_arduino_auto_open_serial = 0
4545
endif
4646

47+
if !exists('g:vim_arduino_sketchbook')
48+
let g:vim_arduino_sketchbook = $HOME."/Documents/Arduino"
49+
endif
50+
51+
if !exists('g:vim_arduino_sdk_home')
52+
let g:vim_arduino_sdk_home = "/Applications/Arduino.app/Contents/Resources/Java"
53+
endif
54+
4755
let s:helper_dir = expand("<sfile>:h")
4856

4957
" Private: Get the board to deploy to
@@ -104,8 +112,10 @@ function! s:InvokeArduinoCli(deploy)
104112
let l:command = s:helper_dir . "/vim-arduino " .
105113
\ l:flag . " " .
106114
\ "-b " . l:board . " " .
115+
\ "-a " . g:vim_arduino_sdk_home . " " .
116+
\ "-k " . g:vim_arduino_sketchbook . " " .
107117
\ shellescape(l:f_name)
108-
" echo l:command
118+
echo l:command
109119
let l:result = system(l:command)
110120
call s:PrintStatus(v:shell_error)
111121
echo l:result

0 commit comments

Comments
 (0)