diff options
author | Scott Prager <splinterofchaos@gmail.com> | 2014-11-10 13:58:37 -0500 |
---|---|---|
committer | Scott Prager <splinterofchaos@gmail.com> | 2015-04-13 10:20:42 -0400 |
commit | 676133aa9b20923e387b77f95d5df55803a5842e (patch) | |
tree | 2772e7b0e622f69e817e9d78e6e5bfa4e6dd94e8 /test/functional/api/server_requests_spec.lua | |
parent | 8d59e74f6ca619f9466cbb8bda107ec8bf399915 (diff) | |
download | rneovim-676133aa9b20923e387b77f95d5df55803a5842e.tar.gz rneovim-676133aa9b20923e387b77f95d5df55803a5842e.tar.bz2 rneovim-676133aa9b20923e387b77f95d5df55803a5842e.zip |
msgpack: Allow notifications to execute commands.
Consider: `let vim = rpcstart('nvim', ['--embed'])`
Allows `rpcnotify(vim, ...)` to work like an asynchronous
`rpcrequest(nvim, ...)`.
Helped-by: Michael Reed <m.reed@mykolab.com>
Helped-by: Justin M. Keyes <>
Diffstat (limited to 'test/functional/api/server_requests_spec.lua')
-rw-r--r-- | test/functional/api/server_requests_spec.lua | 38 |
1 files changed, 36 insertions, 2 deletions
diff --git a/test/functional/api/server_requests_spec.lua b/test/functional/api/server_requests_spec.lua index a37c41294b..a53fd8e006 100644 --- a/test/functional/api/server_requests_spec.lua +++ b/test/functional/api/server_requests_spec.lua @@ -3,8 +3,8 @@ -- be running. local helpers = require('test.functional.helpers') local clear, nvim, eval = helpers.clear, helpers.nvim, helpers.eval -local eq, run, stop = helpers.eq, helpers.run, helpers.stop - +local eq, neq, run, stop = helpers.eq, helpers.neq, helpers.run, helpers.stop +local nvim_prog = helpers.nvim_prog describe('server -> client', function() @@ -115,4 +115,38 @@ describe('server -> client', function() eq(expected, notified) end) end) + + describe('when the client is a recursive vim instance', function() + before_each(function() + nvim('command', "let vim = rpcstart('"..nvim_prog.."', ['--embed'])") + neq(0, eval('vim')) + end) + + after_each(function() nvim('command', 'call rpcstop(vim)') end) + + it('can send/recieve notifications and make requests', function() + nvim('command', "call rpcnotify(vim, 'vim_set_current_line', 'SOME TEXT')") + + -- Wait for the notification to complete. + nvim('command', "call rpcrequest(vim, 'vim_eval', '0')") + + eq('SOME TEXT', eval("rpcrequest(vim, 'vim_get_current_line')")) + end) + + it('can communicate buffers, tabpages, and windows', function() + eq({3}, eval("rpcrequest(vim, 'vim_get_tabpages')")) + eq({1}, eval("rpcrequest(vim, 'vim_get_windows')")) + + local buf = eval("rpcrequest(vim, 'vim_get_buffers')")[1] + eq(2, buf) + + eval("rpcnotify(vim, 'buffer_set_line', "..buf..", 0, 'SOME TEXT')") + nvim('command', "call rpcrequest(vim, 'vim_eval', '0')") -- wait + + eq('SOME TEXT', eval("rpcrequest(vim, 'buffer_get_line', "..buf..", 0)")) + + -- Call get_line_slice(buf, range [0,0], includes start, includes end) + eq({'SOME TEXT'}, eval("rpcrequest(vim, 'buffer_get_line_slice', "..buf..", 0, 0, 1, 1)")) + end) + end) end) |