diff --git a/autoload/denops_shared_server.vim b/autoload/denops_shared_server.vim index cfa409d..97861ff 100644 --- a/autoload/denops_shared_server.vim +++ b/autoload/denops_shared_server.vim @@ -1,12 +1,12 @@ function! denops_shared_server#install() abort if !exists('g:denops_server_addr') - call denops#util#error('No denops shared server address (g:denops_server_addr) is given.') + call denops_shared_server#util#error('No denops shared server address (g:denops_server_addr) is given.') return endif let [hostname, port] = s:parse_server_addr(g:denops_server_addr) let options = { \ 'deno': exepath(g:denops#deno), - \ 'script': denops#util#script_path('@denops-private/cli.ts'), + \ 'script': denops_shared_server#util#script_path('@denops-private/cli.ts'), \ 'hostname': hostname, \ 'port': port, \} @@ -17,14 +17,14 @@ function! denops_shared_server#install() abort elseif executable('systemctl') call denops_shared_server#systemctl#install(options) else - call denops#util#error('This platform is not supported. Please configure denops-shared-server manually.') + call denops_shared_server#util#error('This platform is not supported. Please configure denops-shared-server manually.') return endif - call denops#util#info('wait 5 second for the shared server startup...') + call denops_shared_server#util#info('wait 5 second for the shared server startup...') sleep 5 - call denops#util#info('connect to the shared server') + call denops_shared_server#util#info('connect to the shared server') call denops#server#connect() - call denops#util#info('stop the local server') + call denops_shared_server#util#info('stop the local server') call denops#server#stop() endfunction @@ -36,7 +36,7 @@ function! denops_shared_server#uninstall() abort elseif executable('systemctl') call denops_shared_server#systemctl#uninstall() else - call denops#util#error('This platform is not supported. Please configure denops-shared-server manually.') + call denops_shared_server#util#error('This platform is not supported. Please configure denops-shared-server manually.') return endif endfunction diff --git a/autoload/denops_shared_server/launchctl.vim b/autoload/denops_shared_server/launchctl.vim index 85b8c3e..72028df 100644 --- a/autoload/denops_shared_server/launchctl.vim +++ b/autoload/denops_shared_server/launchctl.vim @@ -14,21 +14,21 @@ function! denops_shared_server#launchctl#install(options) abort \ 'deno_args': join(map(copy(g:denops#server#deno_args), \ { _, val -> printf('%s', val) }), "\n"), \}) - call denops#util#info(printf('create the plist `%s`', s:plist_file)) + call denops_shared_server#util#info(printf('create the plist `%s`', s:plist_file)) call mkdir(fnamemodify(s:plist_file, ':h'), 'p') call writefile(content, s:plist_file, 'b') - call denops#util#info(printf('unload the plist `%s`', s:plist_file)) + call denops_shared_server#util#info(printf('unload the plist `%s`', s:plist_file)) call system(printf('launchctl unload %s', s:plist_file)) - call denops#util#info(printf('load the plist `%s`', s:plist_file)) + call denops_shared_server#util#info(printf('load the plist `%s`', s:plist_file)) echo system(printf('launchctl load -w %s', s:plist_file)) endfunction function! denops_shared_server#launchctl#uninstall() abort - call denops#util#info(printf('unload the plist `%s`', s:plist_file)) + call denops_shared_server#util#info(printf('unload the plist `%s`', s:plist_file)) echo system(printf('launchctl unload %s', s:plist_file)) - call denops#util#info(printf('delete the plist `%s`', s:plist_file)) + call denops_shared_server#util#info(printf('delete the plist `%s`', s:plist_file)) call delete(s:plist_file) endfunction diff --git a/autoload/denops_shared_server/runtray.vim b/autoload/denops_shared_server/runtray.vim index 5b15efb..af29c78 100644 --- a/autoload/denops_shared_server/runtray.vim +++ b/autoload/denops_shared_server/runtray.vim @@ -15,29 +15,29 @@ function! denops_shared_server#runtray#install(options) abort \ 'port': a:options.port, \ 'deno_args': json_encode(g:denops#server#deno_args)[2:-3], \}) - call denops#util#info(printf('create the configuration file `%s`', s:config_file)) + call denops_shared_server#util#info(printf('create the configuration file `%s`', s:config_file)) call mkdir(fnamemodify(s:config_file, ':h'), 'p') call writefile(content, s:config_file, 'b') - call denops#util#info(printf('download the script `%s`', s:script_file)) + call denops_shared_server#util#info(printf('download the script `%s`', s:script_file)) call denops_shared_server#runtray#_download_file(s:script_download_url, s:script_file) call denops_shared_server#runtray#_remove_zone_identifier(s:script_file) - call denops#util#info('install to the startup') + call denops_shared_server#util#info('install to the startup') call denops_shared_server#runtray#_execute_script_command('install') - call denops#util#info('start the service') + call denops_shared_server#util#info('start the service') call denops_shared_server#runtray#_execute_script_command('start') endfunction function! denops_shared_server#runtray#uninstall() abort - call denops#util#info('uninstall from the startup') + call denops_shared_server#util#info('uninstall from the startup') call denops_shared_server#runtray#_execute_script_command('uninstall') - call denops#util#info(printf('delete the configuration file `%s`', s:config_file)) + call denops_shared_server#util#info(printf('delete the configuration file `%s`', s:config_file)) call delete(s:config_file) - call denops#util#info(printf('delete the script `%s`', s:script_file)) + call denops_shared_server#util#info(printf('delete the script `%s`', s:script_file)) call delete(s:script_file) endfunction diff --git a/autoload/denops_shared_server/systemctl.vim b/autoload/denops_shared_server/systemctl.vim index 742fffe..46f7871 100644 --- a/autoload/denops_shared_server/systemctl.vim +++ b/autoload/denops_shared_server/systemctl.vim @@ -11,30 +11,30 @@ function! denops_shared_server#systemctl#install(options) abort \ 'port': a:options.port, \ 'deno_args': join(g:denops#server#deno_args, ' '), \}) - call denops#util#info(printf('create the unit file `%s`', s:unit_file)) + call denops_shared_server#util#info(printf('create the unit file `%s`', s:unit_file)) call mkdir(fnamemodify(s:unit_file, ':h'), 'p') call writefile(content, s:unit_file, 'b') - call denops#util#info(printf('enable the unit `%s`', s:name)) + call denops_shared_server#util#info(printf('enable the unit `%s`', s:name)) echo system(printf('systemctl --user enable %s.service', s:name)) - call denops#util#info(printf('start the unit `%s`', s:name)) + call denops_shared_server#util#info(printf('start the unit `%s`', s:name)) echo system(printf('systemctl --user start %s.service', s:name)) endfunction function! denops_shared_server#systemctl#uninstall() abort - call denops#util#info(printf('stop the unit `%s`', s:name)) + call denops_shared_server#util#info(printf('stop the unit `%s`', s:name)) echo system(printf('systemctl --user stop %s.service', s:name)) - call denops#util#info(printf('disable the unit `%s`', s:name)) + call denops_shared_server#util#info(printf('disable the unit `%s`', s:name)) echo system(printf('systemctl --user disable %s.service', s:name)) - call denops#util#info(printf('delete the unit file `%s`', s:unit_file)) + call denops_shared_server#util#info(printf('delete the unit file `%s`', s:unit_file)) call delete(s:unit_file) - call denops#util#info('daemon reload') + call denops_shared_server#util#info('daemon reload') echo system('systemctl --user daemon-reload') - call denops#util#info('reset failed') + call denops_shared_server#util#info('reset failed') echo system('systemctl --user reset-failed') endfunction diff --git a/autoload/denops_shared_server/util.vim b/autoload/denops_shared_server/util.vim new file mode 100644 index 0000000..5b00447 --- /dev/null +++ b/autoload/denops_shared_server/util.vim @@ -0,0 +1,25 @@ +function! denops_shared_server#util#script_path(path) abort + try + " Denops v4 or later + return denops#_internal#path#script([a:path]) + catch /^Vim\%((\a\+)\)\=:E117:/ + " Denops v3 or prior + return denops#util#script_path(a:path) + endtry +endfunction + +function! denops_shared_server#util#info(...) abort + call s:echomsg('None', a:000) +endfunction + +function! denops_shared_server#util#error(...) abort + call s:echomsg('ErrorMsg', a:000) +endfunction + +function! s:echomsg(hl, msg) abort + execute printf('echohl %s', a:hl) + for l:line in split(join(a:msg), '\n') + echomsg printf('[denops-shared-server] %s', l:line) + endfor + echohl None +endfunction