11" File: arduino.vim
22" Description: Arduino language integration for vim
33" Maintainer: Evergreen
4- " Last Change: July 16th , 2015
4+ " Last Change: July 27th , 2015
55" License: Vim License
66
77" SCRIPT INITIALIZATION {{{
@@ -13,7 +13,13 @@ let b:did_ftplugin = 1
1313" }}}
1414
1515" SETTINGS {{{
16- let g: hardy_arduino_path = get (g: , ' hardy_arduino_path' , ' arduino' )
16+ if has (" mac" )
17+ let default_bin = " /Applications/Arduino.app/Contents/MacOS/Arduino"
18+ else
19+ let default_bin = " arduino" " In the $PATH
20+ endif
21+
22+ let g: hardy_arduino_path = get (g: , ' hardy_arduino_path' , default_bin)
1723
1824let g: hardy_arduino_options = get (g: , ' hardy_arduino_options' , ' ' )
1925
@@ -28,9 +34,9 @@ let g:hardy_window_size = get(g:, 'hardy_window_size', 15)
2834" Run arduino executable with a given command. Returns -1 if the DISPLAY
2935" environment variable is not set.
3036function ! HardyRunArduino (command )
31- if ! exists (" $DISPLAY" )
37+ if ! exists (" $DISPLAY" ) && ! has ( " mac " )
3238 echohl Error
33- echom " Hardy: A graphical user interface such as X must be present"
39+ echom " Hardy: A graphical user interface such as X or OS X must be present"
3440 echohl Normal
3541 return -1
3642 endif
@@ -91,14 +97,14 @@ endfunction
9197
9298" Verify the current file using arduino --verify
9399function ! HardyArduinoVerify ()
94- let l: result = HardyRunArduino (' --verify ' . bufname (" %" ))
100+ let l: result = HardyRunArduino (' --verify ' . expand (" %:p " ))
95101
96102 call HardyShowInfo (l: result )
97103endfunction
98104
99105" Upload the current file using arduino --upload
100106function ! HardyArduinoUpload ()
101- let l: result = HardyRunArduino (' --upload ' . bufname (" %" ))
107+ let l: result = HardyRunArduino (' --upload ' . expand (" %:p " ))
102108
103109 call HardyShowInfo (l: result )
104110endfunction
0 commit comments