<commit_before>let s:vim_arduino_version = '0.1.0'

" Load Once: {{{1
if exists("loaded_vim_platform_io")
    finish
endif
let loaded_vim_platform_io = 1

if !exists('g:vim_platform_io_auto_open_serial')
  let g:vim_platform_io_auto_open_serial = 0
endif

let s:helper_dir = expand("<sfile>:h")

function! s:PrintStatus(result)
  if a:result == 0
    echohl Statement | echomsg "Succeeded." | echohl None
  else
    echohl WarningMsg | echomsg "Failed." | echohl None
  endif
endfunction

" Private: Compile or deploy code
"
" Returns nothing.
function! s:PlatformIoCli(command)
  let l:f_name = expand('%:p')
  execute "w"

  echomsg "Compiling and deploying..." l:f_name
  let l:result = system(a:command)

  echo l:result

"  let l:result2 = system("find .build -name '*.hex' -printf '%p %s bytes'")
"  echo l:result2

  call s:PrintStatus(v:shell_error)

  return !v:shell_error
endfunction

" Public: Clean current project.
"
function! PlatformIoClean()
  call s:PlatformIoCli("platformio run --target clean")
endfunction

" Public: Compile current project.
"
function! PlatformIoBuild()
  call s:PlatformIoCli("platformio run")
endfunction

" Public: Compile and Deploy the current pde file.
"
function! PlatformIoDeploy()
  call s:PlatformIoCli("platformio run -target upload")

  " optionally auto open a serial port
  if g:vim_platform_io_auto_open_serial
    call PlatformIoSerialMonitor()
  endif
endfunction

" Public: Monitor a serial port
"
" Returns nothing.
function! PlatformIoSerialMonitor()
  if ArduinoDeploy()
    echo system(s:helper_dir."/vim-arduino-serial")
  endif
endfunction

if !exists('g:vim_platform_io_map_keys')
  let g:vim_platform_io_map_keys = 1
endif

if g:vim_platform_io_map_keys
  nnoremap <leader>pc :call PlatformIoClean()<CR>
  nnoremap <leader>pb :call PlatformIoBuild()<CR>
  nnoremap <leader>pd :call PlatformIoDeploy()<CR>
  nnoremap <leader>ps :call PlatformIoSerialMonitor()<CR>
endif<commit_msg>Fix wrong upload command<commit_after>let s:vim_arduino_version = '0.1.0'

" Load Once: {{{1
if exists("loaded_vim_platform_io")
    finish
endif
let loaded_vim_platform_io = 1

if !exists('g:vim_platform_io_auto_open_serial')
  let g:vim_platform_io_auto_open_serial = 0
endif

let s:helper_dir = expand("<sfile>:h")

function! s:PrintStatus(result)
  if a:result == 0
    echohl Statement | echomsg "Succeeded." | echohl None
  else
    echohl WarningMsg | echomsg "Failed." | echohl None
  endif
endfunction

" Private: Compile or deploy code
"
" Returns nothing.
function! s:PlatformIoCli(command)
  let l:f_name = expand('%:p')
  execute "w"

  echomsg "Compiling and deploying..." l:f_name
  let l:result = system(a:command)

  echo l:result

"  let l:result2 = system("find .build -name '*.hex' -printf '%p %s bytes'")
"  echo l:result2

  call s:PrintStatus(v:shell_error)

  return !v:shell_error
endfunction

" Public: Clean current project.
"
function! PlatformIoClean()
  call s:PlatformIoCli("platformio run --target clean")
endfunction

" Public: Compile current project.
"
function! PlatformIoBuild()
  call s:PlatformIoCli("platformio run")
endfunction

" Public: Compile and Deploy the current pde file.
"
function! PlatformIoDeploy()
  call s:PlatformIoCli("platformio run --target upload")

  " optionally auto open a serial port
  if g:vim_platform_io_auto_open_serial
    call PlatformIoSerialMonitor()
  endif
endfunction

" Public: Monitor a serial port
"
" Returns nothing.
function! PlatformIoSerialMonitor()
  if ArduinoDeploy()
    echo system(s:helper_dir."/vim-arduino-serial")
  endif
endfunction

if !exists('g:vim_platform_io_map_keys')
  let g:vim_platform_io_map_keys = 1
endif

if g:vim_platform_io_map_keys
  nnoremap <leader>pc :call PlatformIoClean()<CR>
  nnoremap <leader>pb :call PlatformIoBuild()<CR>
  nnoremap <leader>pd :call PlatformIoDeploy()<CR>
  nnoremap <leader>ps :call PlatformIoSerialMonitor()<CR>
endif
{'fraction_non_alphanumeric': 0.10738083034341363, 'fraction_numerical': 0.005125576627370579, 'mean_word_length': 5.2448, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5907790', 'n_tokens_mistral': 1422, 'n_tokens_neox': 1337, 'n_words': 346}