File tree Expand file tree Collapse file tree 1 file changed +57
-0
lines changed
autoload/vital/__vital__/System Expand file tree Collapse file tree 1 file changed +57
-0
lines changed Original file line number Diff line number Diff line change 1+ let s: save_cpoptions = &cpoptions
2+ set cpoptions &vim
3+
4+ let s: is_windows = has (' win32' ) " This means any versions of windows https://github.com/vim-jp/vital.vim/wiki/Coding-Rule#how-to-check-if-the-runtime-os-is-windows
5+
6+ let s: TYPE_DICT = type ({})
7+ let s: TYPE_LIST = type ([])
8+ let s: TYPE_STRING = type (' ' )
9+
10+ function ! s: _vital_loaded (V) abort
11+ let s: V = a: V
12+ endfunction
13+
14+ function ! s: _vital_depends () abort
15+ return []
16+ endfunction
17+
18+ " execute({command}, {options})
19+ " {command} = string
20+ " {options} = {
21+ " out_cb: function,
22+ " err_cb: function,
23+ " exit_cb: function,
24+ " }
25+ function ! s: execute (command , options ) abort
26+
27+ if ! type (a: options ) is s: TYPE_DICT
28+ throw ' vital: AsyncProcess: invalid argument (value type:' . type (a: options ) . ' )'
29+ endif
30+
31+ " Process a:command argument.
32+ if type (a: command ) is s: TYPE_STRING
33+ let command = a: command
34+ elseif type (a: command ) is s: TYPE_LIST
35+ let command = join (a: command , ' ' )
36+ else
37+ throw ' vital: AsyncProcess: invalid argument (value type:' . type (a: command ) . ' )'
38+ endif
39+
40+ " build args
41+ " TODO: support powershell, pwsh
42+ let args = []
43+ if s: is_windows
44+ let args = args + [' /c' ]
45+ else
46+ let args = args + [' -c' ]
47+ endif
48+ let args = args + [command ]
49+
50+ " TODO: support nvim
51+ call job_start ([&shell ] + args , a: options )
52+
53+ endfunction
54+
55+ let &cpoptions = s: save_cpoptions
56+ unlet s: save_cpoptions
57+
You can’t perform that action at this time.
0 commit comments