@@ -25,6 +25,11 @@ let s:SKETCHFILE = v:null
25
25
" Initialization {{{1
26
26
" Set up all user configuration variables
27
27
function ! arduino#InitializeConfig () abort
28
+ if exists (' g:arduino_did_initialize' )
29
+ return
30
+ endif
31
+ call arduino#LoadCache ()
32
+
28
33
if ! exists (' g:arduino_board' )
29
34
if exists (' g:_cache_arduino_board' )
30
35
let g: arduino_board = g: _cache_arduino_board
@@ -87,6 +92,7 @@ function! arduino#InitializeConfig() abort
87
92
au !
88
93
au BufReadPost *.ino call s: ReadSketchJson (expand (' <amatch>:p:h' ))
89
94
aug END
95
+ let g: arduino_did_initialize = 1
90
96
endfunction
91
97
92
98
function ! arduino#RunCmd (cmd) abort
@@ -429,6 +435,7 @@ function! s:ChooserItemOrder(i1, i2) abort
429
435
endfunction
430
436
431
437
function ! arduino#Attach (... ) abort
438
+ call arduino#InitializeConfig ()
432
439
if ! s: has_cli
433
440
echoerr ' ArduinoAttach requires arduino-cli'
434
441
return
@@ -457,6 +464,7 @@ endfunction
457
464
" Port selection {{{2
458
465
459
466
function ! arduino#ChoosePort (... ) abort
467
+ call arduino#InitializeConfig ()
460
468
if a: 0
461
469
let g: arduino_serial_port = a: 1
462
470
return
@@ -480,6 +488,7 @@ let s:callback_data = {}
480
488
481
489
" Display a list of boards to the user and allow them to choose the active one
482
490
function ! arduino#ChooseBoard (... ) abort
491
+ call arduino#InitializeConfig ()
483
492
if a: 0
484
493
call arduino#SetBoard (a: 1 )
485
494
return
@@ -532,6 +541,7 @@ endfunction
532
541
" Programmer selection {{{2
533
542
534
543
function ! arduino#ChooseProgrammer (... ) abort
544
+ call arduino#InitializeConfig ()
535
545
if a: 0
536
546
call arduino#SetProgrammer (a: 1 )
537
547
return
@@ -567,6 +577,7 @@ function! arduino#SetBoard(board, ...) abort
567
577
endfunction
568
578
569
579
function ! arduino#Verify () abort
580
+ call arduino#InitializeConfig ()
570
581
if g: arduino_use_cli
571
582
let cmd = arduino#GetCLICompileCommand ()
572
583
else
@@ -578,6 +589,7 @@ function! arduino#Verify() abort
578
589
endfunction
579
590
580
591
function ! arduino#Upload () abort
592
+ call arduino#InitializeConfig ()
581
593
if g: arduino_use_cli
582
594
let cmd = arduino#GetCLICompileCommand (' -u' )
583
595
else
@@ -594,13 +606,15 @@ function! arduino#Upload() abort
594
606
endfunction
595
607
596
608
function ! arduino#Serial () abort
609
+ call arduino#InitializeConfig ()
597
610
let cmd = arduino#GetSerialCmd ()
598
611
if empty (cmd) | return | endif
599
612
600
613
call arduino#RunCmd (cmd)
601
614
endfunction
602
615
603
616
function ! arduino#UploadAndSerial ()
617
+ call arduino#InitializeConfig ()
604
618
" Since 'terminal!' is non-blocking '!' must be used to provide this functionality
605
619
let termBackup = s: TERM
606
620
let s: TERM = ' !'
@@ -748,6 +762,7 @@ endfunction
748
762
749
763
" Print the current configuration
750
764
function ! arduino#GetInfo () abort
765
+ call arduino#InitializeConfig ()
751
766
let port = arduino#GetPort ()
752
767
if empty (port)
753
768
let port = ' none'
0 commit comments