1
0
mirror of https://github.com/SpaceVim/SpaceVim.git synced 2025-03-23 09:39:58 +08:00

65 lines
1.8 KiB
VimL
Raw Normal View History

2017-10-04 10:02:38 +08:00
"=============================================================================
" server.vim --- server manager for SpaceVim
2023-03-26 13:44:47 +08:00
" Copyright (c) 2016-2023 Wang Shidong & Contributors
2022-03-27 13:38:54 +08:00
" Author: Shidong Wang < wsdjeg@outlook.com >
2017-10-04 10:02:38 +08:00
" URL: https://spacevim.org
2018-02-15 22:25:03 +08:00
" License: GPLv3
2017-10-04 10:02:38 +08:00
"=============================================================================
let s:SYS = SpaceVim#api#import('system')
2017-10-04 13:49:14 +08:00
2017-11-09 20:43:09 +08:00
" This function should not be called twice!
2017-10-04 13:49:14 +08:00
2017-11-09 20:43:09 +08:00
let s:flag = 0
2019-01-28 22:12:37 +08:00
function! SpaceVim#server#connect() abort
2017-11-09 20:43:09 +08:00
if s:flag == 0
if empty($SPACEVIM_SERVER_ADDRESS)
" in windows pipe server is used.
" call serverstart('\\.\pipe\nvim-pipe-1234')
if s:SYS.isWindows
let $SPACEVIM_SERVER_ADDRESS = fnamemodify('\\.\pipe\' . (has('nvim') ? 'spacevim-nvim-' : 'spacevim-vim-') . 'server', ':p')
else
let $SPACEVIM_SERVER_ADDRESS = fnamemodify('/tmp/' . (has('nvim') ? 'spacevim_nvim_' : 'spacevim_vim_') . 'server', ':p')
endif
2017-11-09 20:43:09 +08:00
endif
if has('nvim')
try
call serverstart($SPACEVIM_SERVER_ADDRESS)
call SpaceVim#logger#info('SpaceVim server startup at:' . $SPACEVIM_SERVER_ADDRESS)
2017-11-20 20:06:19 +08:00
catch
2017-11-09 20:43:09 +08:00
endtry
elseif has('clientserver') && exists('*remote_startserver')
if index(split(serverlist(), "\n"), $SPACEVIM_SERVER_ADDRESS) == -1
2017-11-09 20:48:47 +08:00
try
call remote_startserver($SPACEVIM_SERVER_ADDRESS)
call SpaceVim#logger#info('SpaceVim server startup at:' . $SPACEVIM_SERVER_ADDRESS)
catch
2017-11-09 20:48:47 +08:00
endtry
2017-11-09 20:43:09 +08:00
endif
2017-11-08 22:47:56 +08:00
endif
2017-11-09 20:43:09 +08:00
let s:flag = 1
2017-11-08 21:49:09 +08:00
endif
2017-10-04 10:02:38 +08:00
endfunction
2019-01-28 22:12:37 +08:00
function! SpaceVim#server#export_server() abort
2017-11-23 16:29:51 +08:00
if executable('export')
call system('export $TEST_SPACEVIM="test"')
endif
2017-10-04 13:49:14 +08:00
endfunction
2019-01-28 22:12:37 +08:00
function! SpaceVim#server#terminate() abort
2017-10-04 13:49:14 +08:00
endfunction
2019-01-28 22:12:37 +08:00
function! SpaceVim#server#list() abort
2017-11-08 21:49:09 +08:00
if has('nvim')
return join(serverlist(), "\n")
else
endif
2017-10-04 13:49:14 +08:00
endfunction
2017-10-04 10:02:38 +08:00