1
- const s: DENO_VERSION = ' 1.45.0'
2
- const s: VIM_VERSION = ' 9.1.0448'
3
- const s: NEOVIM_VERSION = ' 0.10.0'
1
+ const s: root = resolve (expand (' <sfile>:p:h:h:h' ))
4
2
5
3
function ! s: compare_version (v1, v2) abort
6
- let l: v1 = map (split (a: v1 , ' \.' ), { _, v - > v + 0 })
7
- let l: v2 = map (split (a: v2 , ' \.' ), { _, v - > v + 0 })
4
+ const l: v1 = map (split (a: v1 , ' \.' ), { _, v - > v + 0 })
5
+ const l: v2 = map (split (a: v2 , ' \.' ), { _, v - > v + 0 })
8
6
for l: i in range (max ([len (l: v1 ), len (l: v2 )]))
9
7
let l: t1 = get (l: v1 , l: i , 0 )
10
8
let l: t2 = get (l: v2 , l: i , 0 )
@@ -15,8 +13,16 @@ function! s:compare_version(v1, v2) abort
15
13
return 0
16
14
endfunction
17
15
16
+ function ! s: load_supported_versions () abort
17
+ const l: jsonfile = denops#_internal#path#join ([s: root , ' denops' , ' supported_versions.json' ])
18
+ if ! filereadable (l: jsonfile )
19
+ throw ' Failed to read <runtimepath>/denops/supported_versions.json'
20
+ endif
21
+ return json_decode (join (readfile (l: jsonfile ), " \n " ))
22
+ endfunction
23
+
18
24
function ! s: get_deno_version (deno) abort
19
- let l: output = system (printf (' %s --version' , a: deno ))
25
+ const l: output = system (printf (' %s --version' , a: deno ))
20
26
return matchstr (l: output , ' deno \zs[0-9.]\+' )
21
27
endfunction
22
28
@@ -42,61 +48,49 @@ function! s:check_deno_executable() abort
42
48
call s: report_ok (' Deno executable check: passed' )
43
49
endfunction
44
50
45
- function ! s: check_deno_version () abort
46
- let l: deno_version = s: get_deno_version (g: denops #deno)
47
- call s: report_info (printf (
48
- \ ' Supported Deno version: `%s`' ,
49
- \ s: DENO_VERSION ,
50
- \) )
51
+ function ! s: check_deno_version (supported_version) abort
52
+ const l: deno_version = s: get_deno_version (g: denops #deno)
51
53
call s: report_info (printf (
52
54
\ ' Detected Deno version: `%s`' ,
53
55
\ l: deno_version ,
54
56
\) )
55
57
if empty (l: deno_version )
56
58
call s: report_error (' Unable to detect version of deno, make sure your deno runtime is correct.' )
57
59
return
58
- elseif s: compare_version (l: deno_version , s: DENO_VERSION ) < 0
60
+ elseif s: compare_version (l: deno_version , a: supported_version ) < 0
59
61
call s: report_error (printf (
60
62
\ ' Unsupported Deno version is detected. You need to upgrade it to `%s` or later.' ,
61
- \ s: DENO_VERSION ,
63
+ \ a: supported_version ,
62
64
\) )
63
65
return
64
66
endif
65
67
call s: report_ok (' Deno version check: passed' )
66
68
endfunction
67
69
68
- function ! s: check_vim_version () abort
69
- call s: report_info (printf (
70
- \ ' Supported Vim version: `%s`' ,
71
- \ s: VIM_VERSION ,
72
- \) )
70
+ function ! s: check_vim_version (supported_version) abort
73
71
call s: report_info (printf (
74
72
\ ' Detected Vim version: `%s`' ,
75
73
\ denops#_internal#meta#get ().version ,
76
74
\) )
77
- if ! has (printf (' patch-%s' , s: VIM_VERSION ))
75
+ if ! has (printf (' patch-%s' , a: supported_version ))
78
76
call s: report_error (printf (
79
77
\ ' Unsupported Vim version is detected. You need to upgrade it to `%s` or later.' ,
80
- \ s: VIM_VERSION ,
78
+ \ a: supported_version ,
81
79
\) )
82
80
return
83
81
endif
84
82
call s: report_ok (' Vim version check: passed' )
85
83
endfunction
86
84
87
- function ! s: check_neovim_version () abort
88
- call s: report_info (printf (
89
- \ ' Supported Neovim version: `%s`' ,
90
- \ s: NEOVIM_VERSION ,
91
- \) )
85
+ function ! s: check_neovim_version (supported_version) abort
92
86
call s: report_info (printf (
93
87
\ ' Detected Neovim version: `%s`' ,
94
88
\ denops#_internal#meta#get ().version ,
95
89
\) )
96
- if ! has (printf (' nvim-%s' , s: NEOVIM_VERSION ))
90
+ if ! has (printf (' nvim-%s' , a: supported_version ))
97
91
call s: report_error (printf (
98
92
\ ' Unsupported Neovim version is detected. You need to upgrade it to `%s` or later.' ,
99
- \ s: NEOVIM_VERSION ,
93
+ \ a: supported_version ,
100
94
\) )
101
95
return
102
96
endif
@@ -157,11 +151,24 @@ else
157
151
endif
158
152
159
153
function ! health#denops#check () abort
160
- call s: check_deno_version ()
154
+ const l: supported_versions = s: load_supported_versions ()
155
+ call s: report_info (printf (
156
+ \ ' Supported Deno version: `%s`' ,
157
+ \ l: supported_versions .deno,
158
+ \) )
159
+ call s: report_info (printf (
160
+ \ ' Supported Vim version: `%s`' ,
161
+ \ l: supported_versions .vim ,
162
+ \) )
163
+ call s: report_info (printf (
164
+ \ ' Supported Neovim version: `%s`' ,
165
+ \ l: supported_versions .neovim,
166
+ \) )
167
+ call s: check_deno_version (l: supported_versions .deno)
161
168
if ! has (' nvim' )
162
- call s: check_vim_version ()
169
+ call s: check_vim_version (l: supported_versions . vim )
163
170
else
164
- call s: check_neovim_version ()
171
+ call s: check_neovim_version (l: supported_versions .neovim )
165
172
endif
166
173
call s: check_denops ()
167
174
call s: check_denops_status ()
0 commit comments