aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/_editor.lua
diff options
context:
space:
mode:
Diffstat (limited to 'runtime/lua/vim/_editor.lua')
-rw-r--r--runtime/lua/vim/_editor.lua72
1 files changed, 72 insertions, 0 deletions
diff --git a/runtime/lua/vim/_editor.lua b/runtime/lua/vim/_editor.lua
index 3136e36043..5f3d66e108 100644
--- a/runtime/lua/vim/_editor.lua
+++ b/runtime/lua/vim/_editor.lua
@@ -636,6 +636,78 @@ function vim.pretty_print(...)
return ...
end
+local function __rpcrequest(...)
+ return vim.api.nvim_call_function("rpcrequest", {...})
+end
+
+function vim._cs_remote(rcid, args)
+
+ local f_silent = false
+ local f_wait = false
+ local f_tab = false
+ local should_exit = true
+ local command = 'edit '
+
+ local subcmd = string.sub(args[1],10)
+
+ if subcmd == '' then
+ -- no flags to set
+ elseif 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 == '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
+ __rpcrequest(rcid, 'nvim_input', args[2])
+ return { should_exit = should_exit, tabbed = f_tab, files = 0 }
+ -- should we show warning if --server doesn't exist in --send and --expr?
+ elseif subcmd == 'expr' then
+ local res = __rpcrequest(rcid, 'vim_eval', args[2])
+ print(res)
+ return { should_exit = should_exit, tabbed = f_tab, files = 0 }
+ else
+ print('--remote subcommand not found')
+ end
+
+ table.remove(args,1)
+
+ if not f_silent and rcid == 0 then
+ print('Remote server does not exist.')
+ end
+
+ if f_silent and rcid == 0 then
+ print('Remote server does not exist. starting new server')
+ should_exit = false
+ end
+
+ if f_tab then command = 'tabedit ' end
+
+ if rcid ~= 0 then
+ for _, key in ipairs(args) do
+ __rpcrequest(rcid, 'nvim_command', command .. key)
+ end
+ end
+
+ return {
+ should_exit = should_exit,
+ tabbed = f_tab,
+ files = table.getn(args)
+ }
+end
require('vim._meta')