-
Notifications
You must be signed in to change notification settings - Fork 24
Added Windows support #57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -4,11 +4,11 @@ endif | |||
let g:loaded_arduino_autoload = 1 | ||||
let s:has_cli = executable('arduino-cli') == 1 | ||||
if has('win64') || has('win32') || has('win16') | ||||
echoerr 'vim-arduino does not support windows :(' | ||||
finish | ||||
let s:OS = 'Windows' | ||||
else | ||||
let s:OS = substitute(system('uname'), '\n', '', '') | ||||
endif | ||||
let s:HERE = resolve(expand('<sfile>:p:h:h')) | ||||
let s:OS = substitute(system('uname'), '\n', '', '') | ||||
" In neovim, run the shell commands using :terminal to preserve interactivity | ||||
if has('nvim') | ||||
let s:TERM = 'botright split | terminal! ' | ||||
|
@@ -47,6 +47,11 @@ function! arduino#InitializeConfig() abort | |||
endif | ||||
if !exists('g:arduino_serial_cmd') | ||||
let g:arduino_serial_cmd = 'screen {port} {baud}' | ||||
if s:OS ==? 'Windows' | ||||
let g:arduino_serial_cmd = 'arduino-cli monitor -p {port} --config baudrate={baud}' | ||||
else | ||||
let g:arduino_serial_cmd = 'screen {port} {baud}' | ||||
endif | ||||
endif | ||||
if !exists('g:arduino_build_path') | ||||
let g:arduino_build_path = '{project_dir}/build' | ||||
|
@@ -195,8 +200,8 @@ function! arduino#GetBuildPath() abort | |||
return '' | ||||
endif | ||||
let l:path = g:arduino_build_path | ||||
let l:path = substitute(l:path, '{file}', expand('%:p'), 'g') | ||||
let l:path = substitute(l:path, '{project_dir}', expand('%:p:h'), 'g') | ||||
let l:path = substitute(l:path, '{file}', substitute(expand('%:p'), '\', '/', 'g'), 'g') | ||||
let l:path = substitute(l:path, '{project_dir}', substitute(expand('%:p:h'), '\', '/', 'g'), 'g') | ||||
Comment on lines
+198
to
+199
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this what you mean when you say the nested substitutes are not working? What specifically isn't working about them? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I apologize for the confusion. Nested substitutions work fine. I will write another message about what is working as I not expecting. I used this hack to make it work on Windows. I don't know why any path on Windows is composed using backslashes. Without changing slashes topmost |
||||
return l:path | ||||
endfunction | ||||
|
||||
|
@@ -648,6 +653,12 @@ function! arduino#GetPorts() abort | |||
call add(ports, port) | ||||
endfor | ||||
endfor | ||||
if s:OS ==? 'Windows' | ||||
let found = split(system('pwsh -nop -c "arduino-cli board list | Select-String -Pattern \"^(COM\d) \" | ForEach-Object { $_.Matches.Value }"'), '\n') | ||||
for port in found | ||||
call add(ports, port) | ||||
endfor | ||||
endif | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would prefer if you could call vim-arduino/autoload/arduino.vim Line 251 in 111db61
If not, you could still just call There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This makes sense. I'm gonna change it. |
||||
return ports | ||||
endfunction | ||||
|
||||
|
@@ -741,6 +752,8 @@ function! arduino#GetArduinoHomeDir() abort | |||
endif | ||||
if s:OS ==? 'Darwin' | ||||
return $HOME . '/Library/Arduino15' | ||||
elseif s:OS ==? 'Windows' | ||||
return $HOME . '/AppData/Local/Arduino15' | ||||
endif | ||||
|
||||
return $HOME . '/.arduino15' | ||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the arduino-cli supports reading the serial output now, we should just use this as the new default (provided
s:has_cli
)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this is supported. In fact, I didn't know it wasn't supported before. I think it is a good idea to use it as default.