1
1
" ======================================================================
2
2
"
3
- " runner_load .vim -
3
+ " script_load .vim - load scripts in autoload/asyncrun/{runner,program}
4
4
"
5
5
" Created by skywind on 2021/12/15
6
6
" Last Modified: 2021/12/15 05:40:55
15
15
" ----------------------------------------------------------------------
16
16
let g: asyncrun_event = get (g: , ' asyncrun_event' , {})
17
17
let g: asyncrun_runner = get (g: , ' asyncrun_runner' , {})
18
+ let g: asyncrun_program = get (g: , ' asyncrun_program' , {})
18
19
let s: script_time = {}
19
20
20
21
21
22
" ----------------------------------------------------------------------
22
23
" find script
23
24
" ----------------------------------------------------------------------
24
- function ! s: find_script (name)
25
- let test = ' autoload/asyncrun/runner /' . a: name . ' .vim'
25
+ function ! s: find_script (where, name)
26
+ let test = ' autoload/asyncrun/' . a: where . ' /' . a: name . ' .vim'
26
27
let fn = findfile (test, &rtp )
27
28
if fn == ' '
28
29
return ' '
@@ -38,7 +39,7 @@ endfunc
38
39
" ----------------------------------------------------------------------
39
40
function ! s: load_runner (name)
40
41
let name = a: name
41
- let load = s: find_script (name)
42
+ let load = s: find_script (' runner ' , name)
42
43
let test = ' asyncrun#runner#' . name . ' #run'
43
44
if filereadable (load) && load != ' '
44
45
let mtime = getftime (load)
@@ -54,6 +55,27 @@ function! s:load_runner(name)
54
55
endfunc
55
56
56
57
58
+ " ----------------------------------------------------------------------
59
+ " load program
60
+ " ----------------------------------------------------------------------
61
+ function ! s: load_program (name)
62
+ let name = a: name
63
+ let load = s: find_script (' program' , name)
64
+ let test = ' asyncrun#program#' . name . ' #translate'
65
+ if filereadable (load) && load != ' '
66
+ let mtime = getftime (load)
67
+ let ltime = get (s: script_time , load, 0 )
68
+ if mtime > ltime
69
+ exec ' source ' . fnameescape (load)
70
+ let s: script_time [load] = mtime
71
+ endif
72
+ if exists (' *' . test)
73
+ let g: asyncrun_program [name] = test
74
+ endif
75
+ endif
76
+ endfunc
77
+
78
+
57
79
" ----------------------------------------------------------------------
58
80
" init runner
59
81
" ----------------------------------------------------------------------
@@ -63,3 +85,11 @@ endfunc
63
85
64
86
65
87
88
+ " ----------------------------------------------------------------------
89
+ " init program
90
+ " ----------------------------------------------------------------------
91
+ function ! g: asyncrun_event .program (name)
92
+ call s: load_program (a: name )
93
+ endfunc
94
+
95
+
0 commit comments