Skip to content

Commit 11ea193

Browse files
authored
Merge pull request #10 from vim-denops/support-v4
Support denops v4
2 parents dae08df + 17da1ff commit 11ea193

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
@@ -14,21 +14,21 @@ function! denops_shared_server#launchctl#install(options) abort
1414
\ 'deno_args': join(map(copy(g:denops#server#deno_args),
1515
\ { _, val -> printf('<string>%s</string>', val) }), "\n"),
1616
\})
17-
call denops#util#info(printf('create the plist `%s`', s:plist_file))
17+
call denops_shared_server#util#info(printf('create the plist `%s`', s:plist_file))
1818
call mkdir(fnamemodify(s:plist_file, ':h'), 'p')
1919
call writefile(content, s:plist_file, 'b')
2020

21-
call denops#util#info(printf('unload the plist `%s`', s:plist_file))
21+
call denops_shared_server#util#info(printf('unload the plist `%s`', s:plist_file))
2222
call system(printf('launchctl unload %s', s:plist_file))
2323

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

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

32-
call denops#util#info(printf('delete the plist `%s`', s:plist_file))
32+
call denops_shared_server#util#info(printf('delete the plist `%s`', s:plist_file))
3333
call delete(s:plist_file)
3434
endfunction

autoload/denops_shared_server/runtray.vim

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,29 +15,29 @@ function! denops_shared_server#runtray#install(options) abort
1515
\ 'port': a:options.port,
1616
\ 'deno_args': json_encode(g:denops#server#deno_args)[2:-3],
1717
\})
18-
call denops#util#info(printf('create the configuration file `%s`', s:config_file))
18+
call denops_shared_server#util#info(printf('create the configuration file `%s`', s:config_file))
1919
call mkdir(fnamemodify(s:config_file, ':h'), 'p')
2020
call writefile(content, s:config_file, 'b')
2121

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

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

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

3333
function! denops_shared_server#runtray#uninstall() abort
34-
call denops#util#info('uninstall from the startup')
34+
call denops_shared_server#util#info('uninstall from the startup')
3535
call denops_shared_server#runtray#_execute_script_command('uninstall')
3636

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

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

autoload/denops_shared_server/systemctl.vim

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

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

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

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

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

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

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

38-
call denops#util#info('reset failed')
38+
call denops_shared_server#util#info('reset failed')
3939
echo system('systemctl --user reset-failed')
4040
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)