diff options
author | Charlie Groves <charlie.groves@gmail.com> | 2022-03-11 11:16:34 -0500 |
---|---|---|
committer | Charlie Groves <charlie.groves@gmail.com> | 2022-03-11 11:16:46 -0500 |
commit | 1dbf8675c71dc500ae7502085161cd56e311ccf6 (patch) | |
tree | 5fee4a05f87319ee436d8f60516312231610a476 /runtime/lua/vim/_editor.lua | |
parent | 2be938a2513b1dd604ce0069667b89a64441cb2a (diff) | |
download | rneovim-1dbf8675c71dc500ae7502085161cd56e311ccf6.tar.gz rneovim-1dbf8675c71dc500ae7502085161cd56e311ccf6.tar.bz2 rneovim-1dbf8675c71dc500ae7502085161cd56e311ccf6.zip |
fix(remote): respect silent in error reporting
Diffstat (limited to 'runtime/lua/vim/_editor.lua')
-rw-r--r-- | runtime/lua/vim/_editor.lua | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/runtime/lua/vim/_editor.lua b/runtime/lua/vim/_editor.lua index 030c3b40e8..a0c60a7dcf 100644 --- a/runtime/lua/vim/_editor.lua +++ b/runtime/lua/vim/_editor.lua @@ -636,12 +636,24 @@ function vim.pretty_print(...) return ... end -function vim._cs_remote(rcid, args) +function vim._cs_remote(rcid, server_addr, connect_error, args) + local function connection_failure_errmsg(consequence) + local explanation + if server_addr == '' then + explanation = "No server specified with --server" + else + explanation = "Failed to connect to '" .. server_addr .. "'" + if connect_error ~= "" then + explanation = explanation .. ": " .. connect_error + end + end + return "E247: " .. explanation .. ". " .. consequence + end + local f_silent = false local f_tab = false local subcmd = string.sub(args[1],10) - if subcmd == 'tab' then f_tab = true elseif subcmd == 'silent' then @@ -653,13 +665,13 @@ function vim._cs_remote(rcid, args) f_silent = true elseif subcmd == 'send' then if rcid == 0 then - return { errmsg = 'E247: Remote server does not exist. Send failed.' } + return { errmsg = connection_failure_errmsg('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 - return { errmsg = 'E247: Remote server does not exist. Send expression failed.' } + return { errmsg = connection_failure_errmsg('Send expression failed.') } end print(vim.fn.rpcrequest(rcid, 'nvim_eval', args[2])) return { should_exit = true, tabbed = false } @@ -669,7 +681,7 @@ function vim._cs_remote(rcid, args) if rcid == 0 then if not f_silent then - vim.cmd('echohl WarningMsg | echomsg "E247: Remote server does not exist. Editing locally" | echohl None') + vim.notify(connection_failure_errmsg("Editing locally"), vim.log.levels.WARN) end else local command = {} |