-
-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy pathcache.vim
More file actions
46 lines (38 loc) · 1.4 KB
/
cache.vim
File metadata and controls
46 lines (38 loc) · 1.4 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
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()
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'),
\ env: #{
\ NO_COLOR: 1,
\ DENO_NO_PROMPT: 1,
\ },
\})
call denops#_internal#wait#for(60 * 1000, { -> s:job is# v:null }, 100)
endfor
echomsg '[denops] Deno cache is updated.'
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(job, status, event) abort
let s:job = v:null
endfunction