Skip to content

Commit 17da1ff

Browse files
committed
Support denops v4
1 parent 7d33db6 commit 17da1ff

File tree

5 files changed

+52
-27
lines changed

5 files changed

+52
-27
lines changed

autoload/denops_shared_server.vim

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
function! denops_shared_server#install() abort
22
if !exists('g:denops_server_addr')
3-
call denops#util#error('No denops shared server address (g:denops_server_addr) is given.')
3+
call denops_shared_server#util#error('No denops shared server address (g:denops_server_addr) is given.')
44
return
55
endif
66
let [hostname, port] = s:parse_server_addr(g:denops_server_addr)
77
let options = {
88
\ 'deno': exepath(g:denops#deno),
9-
\ 'script': denops#util#script_path('@denops-private/cli.ts'),
9+
\ 'script': denops_shared_server#util#script_path('@denops-private/cli.ts'),
1010
\ 'hostname': hostname,
1111
\ 'port': port,
1212
\}
@@ -17,14 +17,14 @@ function! denops_shared_server#install() abort
1717
elseif executable('systemctl')
1818
call denops_shared_server#systemctl#install(options)
1919
else
20-
call denops#util#error('This platform is not supported. Please configure denops-shared-server manually.')
20+
call denops_shared_server#util#error('This platform is not supported. Please configure denops-shared-server manually.')
2121
return
2222
endif
23-
call denops#util#info('wait 5 second for the shared server startup...')
23+
call denops_shared_server#util#info('wait 5 second for the shared server startup...')
2424
sleep 5
25-
call denops#util#info('connect to the shared server')
25+
call denops_shared_server#util#info('connect to the shared server')
2626
call denops#server#connect()
27-
call denops#util#info('stop the local server')
27+
call denops_shared_server#util#info('stop the local server')
2828
call denops#server#stop()
2929
endfunction
3030

@@ -36,7 +36,7 @@ function! denops_shared_server#uninstall() abort
3636
elseif executable('systemctl')
3737
call denops_shared_server#systemctl#uninstall()
3838
else
39-
call denops#util#error('This platform is not supported. Please configure denops-shared-server manually.')
39+
call denops_shared_server#util#error('This platform is not supported. Please configure denops-shared-server manually.')
4040
return
4141
endif
4242
endfunction

autoload/denops_shared_server/launchctl.vim

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,21 @@ function! denops_shared_server#launchctl#install(options) abort
1212
\ 'hostname': a:options.hostname,
1313
\ 'port': a:options.port,
1414
\})
15-
call denops#util#info(printf('create the plist `%s`', s:plist_file))
15+
call denops_shared_server#util#info(printf('create the plist `%s`', s:plist_file))
1616
call mkdir(fnamemodify(s:plist_file, ':h'), 'p')
1717
call writefile(content, s:plist_file, 'b')
1818

19-
call denops#util#info(printf('unload the plist `%s`', s:plist_file))
19+
call denops_shared_server#util#info(printf('unload the plist `%s`', s:plist_file))
2020
call system(printf('launchctl unload %s', s:plist_file))
2121

22-
call denops#util#info(printf('load the plist `%s`', s:plist_file))
22+
call denops_shared_server#util#info(printf('load the plist `%s`', s:plist_file))
2323
echo system(printf('launchctl load -w %s', s:plist_file))
2424
endfunction
2525

2626
function! denops_shared_server#launchctl#uninstall() abort
27-
call denops#util#info(printf('unload the plist `%s`', s:plist_file))
27+
call denops_shared_server#util#info(printf('unload the plist `%s`', s:plist_file))
2828
echo system(printf('launchctl unload %s', s:plist_file))
2929

30-
call denops#util#info(printf('delete the plist `%s`', s:plist_file))
30+
call denops_shared_server#util#info(printf('delete the plist `%s`', s:plist_file))
3131
call delete(s:plist_file)
3232
endfunction

autoload/denops_shared_server/runtray.vim

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,29 +14,29 @@ function! denops_shared_server#runtray#install(options) abort
1414
\ 'hostname': a:options.hostname,
1515
\ 'port': a:options.port,
1616
\})
17-
call denops#util#info(printf('create the configuration file `%s`', s:config_file))
17+
call denops_shared_server#util#info(printf('create the configuration file `%s`', s:config_file))
1818
call mkdir(fnamemodify(s:config_file, ':h'), 'p')
1919
call writefile(content, s:config_file, 'b')
2020

21-
call denops#util#info(printf('download the script `%s`', s:script_file))
21+
call denops_shared_server#util#info(printf('download the script `%s`', s:script_file))
2222
call denops_shared_server#runtray#_download_file(s:script_download_url, s:script_file)
2323
call denops_shared_server#runtray#_remove_zone_identifier(s:script_file)
2424

25-
call denops#util#info('install to the startup')
25+
call denops_shared_server#util#info('install to the startup')
2626
call denops_shared_server#runtray#_execute_script_command('install')
2727

28-
call denops#util#info('start the service')
28+
call denops_shared_server#util#info('start the service')
2929
call denops_shared_server#runtray#_execute_script_command('start')
3030
endfunction
3131

3232
function! denops_shared_server#runtray#uninstall() abort
33-
call denops#util#info('uninstall from the startup')
33+
call denops_shared_server#util#info('uninstall from the startup')
3434
call denops_shared_server#runtray#_execute_script_command('uninstall')
3535

36-
call denops#util#info(printf('delete the configuration file `%s`', s:config_file))
36+
call denops_shared_server#util#info(printf('delete the configuration file `%s`', s:config_file))
3737
call delete(s:config_file)
3838

39-
call denops#util#info(printf('delete the script `%s`', s:script_file))
39+
call denops_shared_server#util#info(printf('delete the script `%s`', s:script_file))
4040
call delete(s:script_file)
4141
endfunction
4242

autoload/denops_shared_server/systemctl.vim

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,30 +10,30 @@ function! denops_shared_server#systemctl#install(options) abort
1010
\ 'hostname': a:options.hostname,
1111
\ 'port': a:options.port,
1212
\})
13-
call denops#util#info(printf('create the unit file `%s`', s:unit_file))
13+
call denops_shared_server#util#info(printf('create the unit file `%s`', s:unit_file))
1414
call mkdir(fnamemodify(s:unit_file, ':h'), 'p')
1515
call writefile(content, s:unit_file, 'b')
1616

17-
call denops#util#info(printf('enable the unit `%s`', s:name))
17+
call denops_shared_server#util#info(printf('enable the unit `%s`', s:name))
1818
echo system(printf('systemctl --user enable %s.service', s:name))
1919

20-
call denops#util#info(printf('start the unit `%s`', s:name))
20+
call denops_shared_server#util#info(printf('start the unit `%s`', s:name))
2121
echo system(printf('systemctl --user start %s.service', s:name))
2222
endfunction
2323

2424
function! denops_shared_server#systemctl#uninstall() abort
25-
call denops#util#info(printf('stop the unit `%s`', s:name))
25+
call denops_shared_server#util#info(printf('stop the unit `%s`', s:name))
2626
echo system(printf('systemctl --user stop %s.service', s:name))
2727

28-
call denops#util#info(printf('disable the unit `%s`', s:name))
28+
call denops_shared_server#util#info(printf('disable the unit `%s`', s:name))
2929
echo system(printf('systemctl --user disable %s.service', s:name))
3030

31-
call denops#util#info(printf('delete the unit file `%s`', s:unit_file))
31+
call denops_shared_server#util#info(printf('delete the unit file `%s`', s:unit_file))
3232
call delete(s:unit_file)
3333

34-
call denops#util#info('daemon reload')
34+
call denops_shared_server#util#info('daemon reload')
3535
echo system('systemctl --user daemon-reload')
3636

37-
call denops#util#info('reset failed')
37+
call denops_shared_server#util#info('reset failed')
3838
echo system('systemctl --user reset-failed')
3939
endfunction
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
function! denops_shared_server#util#script_path(path) abort
2+
try
3+
" Denops v4 or later
4+
return denops#_internal#path#script([a:path])
5+
catch /^Vim\%((\a\+)\)\=:E117:/
6+
" Denops v3 or prior
7+
return denops#util#script_path(a:path)
8+
endtry
9+
endfunction
10+
11+
function! denops_shared_server#util#info(...) abort
12+
call s:echomsg('None', a:000)
13+
endfunction
14+
15+
function! denops_shared_server#util#error(...) abort
16+
call s:echomsg('ErrorMsg', a:000)
17+
endfunction
18+
19+
function! s:echomsg(hl, msg) abort
20+
execute printf('echohl %s', a:hl)
21+
for l:line in split(join(a:msg), '\n')
22+
echomsg printf('[denops-shared-server] %s', l:line)
23+
endfor
24+
echohl None
25+
endfunction

0 commit comments

Comments
 (0)