-
-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy pathcache.vim
More file actions
59 lines (51 loc) · 1.78 KB
/
cache.vim
File metadata and controls
59 lines (51 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
const s:root = expand('<sfile>:p:h:h:h')
const s:mod = denops#_internal#path#join([s:root, 'denops', '@denops-private', 'mod.ts'])
let s:job = v:null
function! denops#cache#update(...) abort
const l:options = extend(#{ reload: v:false }, a:0 ? a:1 : {})
const l:plugins = denops#_internal#plugin#list()
let l:failures = []
if !l:options.reload
echomsg '[denops] Update cache of the following files. Call `denops#cache#update(#{reload: v:true})` to forcibly update.'
endif
for l:entryfile in [s:mod] + mapnew(l:plugins, { _, v -> v.script })
echomsg printf('[denops] %s', l:entryfile)
let l:args = [g:denops#deno, 'cache']
if l:options.reload
let l:args = add(l:args, '--reload')
endif
let l:args = add(l:args, l:entryfile)
let s:job = denops#_internal#job#start(l:args, #{
\ on_stderr: funcref('s:on_stderr'),
\ on_exit: funcref('s:on_exit', [l:failures, l:entryfile]),
\ env: #{
\ NO_COLOR: 1,
\ DENO_NO_PROMPT: 1,
\ },
\})
call denops#_internal#wait#for(60 * 1000, { -> s:job is# v:null }, 100)
endfor
if empty(l:failures)
echomsg '[denops] Deno cache is updated.'
else
echohl WarningMsg
echomsg printf('[denops] Deno cache finished with errors: %d failure(s).', len(l:failures))
for l:f in l:failures
echomsg printf('[denops] failed: %s', l:f)
endfor
echohl None
endif
endfunction
function! s:on_stderr(job, data, event) abort
echohl Comment
for l:line in split(a:data, '\n')
echomsg printf('[denops] %s', substitute(l:line, '\t', ' ', 'g'))
endfor
echohl None
endfunction
function! s:on_exit(failures, entryfile, job, status, event) abort
if a:status != 0
call add(a:failures, a:entryfile)
endif
let s:job = v:null
endfunction