mirror of
https://github.com/neovim/neovim.git
synced 2024-12-29 14:41:06 -07:00
fix(remote): report on missing wait commands, typecheck lua results
Clean up lint errors, too
This commit is contained in:
parent
e095a868cb
commit
29c3632285
@ -83,7 +83,7 @@ You can not put options there!
|
||||
|
||||
|
||||
==============================================================================
|
||||
2. Missing functionality *clientserver-missing*
|
||||
2. Missing functionality *E5600* *clientserver-missing*
|
||||
|
||||
Vim supports additional functionality in clientserver that's not yet
|
||||
implemented in Nvim. In particular, none of the 'wait' variants are supported
|
||||
|
@ -638,56 +638,39 @@ end
|
||||
|
||||
function vim._cs_remote(rcid, args)
|
||||
local f_silent = false
|
||||
local f_wait = false
|
||||
local f_tab = false
|
||||
|
||||
local subcmd = string.sub(args[1],10)
|
||||
|
||||
if subcmd == '' then
|
||||
-- no flags to set
|
||||
elseif subcmd == 'tab' then
|
||||
if subcmd == 'tab' then
|
||||
f_tab = true
|
||||
elseif subcmd == 'silent' then
|
||||
f_silent = true
|
||||
elseif subcmd == 'wait' then
|
||||
f_wait = true
|
||||
elseif subcmd == 'wait-silent' then
|
||||
f_wait = true
|
||||
f_silent = true
|
||||
elseif subcmd == 'tab-wait' then
|
||||
f_tab = true
|
||||
f_wait = true
|
||||
elseif subcmd == 'wait' or subcmd == 'wait-silent' or subcmd == 'tab-wait' or subcmd == 'tab-wait-silent' then
|
||||
return { errmsg = 'E5600: Wait commands not yet implemented in nvim' }
|
||||
elseif subcmd == 'tab-silent' then
|
||||
f_tab = true
|
||||
f_silent = true
|
||||
elseif subcmd == 'tab-wait-silent' then
|
||||
f_tab = true
|
||||
f_wait = true
|
||||
f_silent = true
|
||||
elseif subcmd == 'send' then
|
||||
if rcid == 0 then
|
||||
vim.cmd('echoerr "E247: Remote server does not exist. Send failed."')
|
||||
return
|
||||
return { errmsg = 'E247: Remote server does not exist. Send failed.' }
|
||||
end
|
||||
vim.fn.rpcrequest(rcid, 'nvim_input', args[2])
|
||||
return { should_exit = true, tabbed = false }
|
||||
elseif subcmd == 'expr' then
|
||||
if rcid == 0 then
|
||||
vim.cmd('echoerr "E247: Remote server does not exist. Send expression failed."')
|
||||
return
|
||||
return { errmsg = 'E247: Remote server does not exist. Send expression failed.' }
|
||||
end
|
||||
vim.fn.rpcrequest(rcid, 'nvim_eval', args[2])
|
||||
print(vim.fn.rpcrequest(rcid, 'nvim_eval', args[2]))
|
||||
return { should_exit = true, tabbed = false }
|
||||
else
|
||||
vim.cmd('echoerr "Unknown option argument: ' .. args[1] .. '"')
|
||||
return
|
||||
elseif subcmd ~= '' then
|
||||
return { errmsg='Unknown option argument: ' .. args[1] }
|
||||
end
|
||||
|
||||
if rcid == 0 then
|
||||
if not f_silent then
|
||||
vim.cmd('echohl WarningMsg | echomsg "E247: Remote server does not exist. Editing locally" | echohl None')
|
||||
end
|
||||
should_exit = false
|
||||
else
|
||||
local command = {}
|
||||
if f_tab then table.insert(command, 'tab') end
|
||||
|
@ -816,8 +816,10 @@ static void handle_remote_client(mparm_T *params, int remote_args,
|
||||
rvobj.type = kObjectTypeDictionary;
|
||||
CallbackReader on_data = CALLBACK_READER_INIT;
|
||||
const char *error = NULL;
|
||||
uint64_t rc_id = server_addr == NULL ? 0 : channel_connect(false,
|
||||
server_addr, true, on_data, 50, &error);
|
||||
uint64_t rc_id = 0;
|
||||
if (server_addr != NULL) {
|
||||
rc_id = channel_connect(false, server_addr, true, on_data, 50, &error);
|
||||
}
|
||||
|
||||
Boolean should_exit = true;
|
||||
Boolean tabbed;
|
||||
@ -848,17 +850,33 @@ static void handle_remote_client(mparm_T *params, int remote_args,
|
||||
rvobj.data.dictionary = o.data.dictionary;
|
||||
} else {
|
||||
mch_errmsg("vim._cs_remote returned unexpected value\n");
|
||||
os_exit(3);
|
||||
os_exit(2);
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < rvobj.data.dictionary.size ; i++) {
|
||||
if (strcmp(rvobj.data.dictionary.items[i].key.data, "tabbed") == 0) {
|
||||
// should we check items[i].value.type here?
|
||||
if (strcmp(rvobj.data.dictionary.items[i].key.data, "errmsg") == 0) {
|
||||
if (rvobj.data.dictionary.items[i].value.type != kObjectTypeString) {
|
||||
mch_errmsg("vim._cs_remote returned an unexpected type for 'errmsg'\n");
|
||||
os_exit(2);
|
||||
}
|
||||
mch_errmsg(rvobj.data.dictionary.items[i].value.data.string.data);
|
||||
mch_errmsg("\n");
|
||||
os_exit(2);
|
||||
} else if (strcmp(rvobj.data.dictionary.items[i].key.data, "tabbed") == 0) {
|
||||
if (rvobj.data.dictionary.items[i].value.type != kObjectTypeBoolean) {
|
||||
mch_errmsg("vim._cs_remote returned an unexpected type for 'tabbed'\n");
|
||||
os_exit(2);
|
||||
}
|
||||
tabbed = rvobj.data.dictionary.items[i].value.data.boolean;
|
||||
} else if (strcmp(rvobj.data.dictionary.items[i].key.data, "should_exit") == 0) {
|
||||
if (rvobj.data.dictionary.items[i].value.type != kObjectTypeBoolean) {
|
||||
mch_errmsg("vim._cs_remote returned an unexpected type for 'should_exit'\n");
|
||||
os_exit(2);
|
||||
}
|
||||
should_exit = rvobj.data.dictionary.items[i].value.data.boolean;
|
||||
}
|
||||
}
|
||||
api_free_object(o);
|
||||
|
||||
if (should_exit) {
|
||||
os_exit(0);
|
||||
|
@ -9,7 +9,6 @@ local insert = helpers.insert
|
||||
local meths = helpers.meths
|
||||
local new_argv = helpers.new_argv
|
||||
local neq = helpers.neq
|
||||
local run = helpers.run
|
||||
local set_session = helpers.set_session
|
||||
local spawn = helpers.spawn
|
||||
local tmpname = helpers.tmpname
|
||||
@ -38,7 +37,7 @@ describe('Remote', function()
|
||||
server:close()
|
||||
end)
|
||||
|
||||
function run_remote(...)
|
||||
local function run_remote(...)
|
||||
set_session(server)
|
||||
local addr = funcs.serverlist()[1]
|
||||
local client_argv = new_argv({args={'--server', addr, ...}})
|
||||
@ -121,7 +120,7 @@ describe('Remote', function()
|
||||
-- to wait for the remote instance to exit and calling jobwait blocks
|
||||
-- the event loop. If the server event loop is blocked, it can't process
|
||||
-- our incoming --remote calls.
|
||||
local client_starter = clear()
|
||||
clear()
|
||||
local bogus_job_id = funcs.jobstart(bogus_argv)
|
||||
eq({2}, funcs.jobwait({bogus_job_id}))
|
||||
end
|
||||
@ -136,5 +135,8 @@ describe('Remote', function()
|
||||
it('expr without server', function()
|
||||
run_and_check_exit_code('--remote-expr', 'setline(1, "Yo")')
|
||||
end)
|
||||
it('wait subcommand', function()
|
||||
run_and_check_exit_code('--remote-wait', fname)
|
||||
end)
|
||||
end)
|
||||
end)
|
||||
|
Loading…
Reference in New Issue
Block a user