diff options
author | Björn Linse <bjorn.linse@gmail.com> | 2016-08-20 12:58:37 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-08-20 12:58:37 +0200 |
commit | 71b3e20d0fba20d4957c1949352bde1744a0a947 (patch) | |
tree | 7844b2d185b27a0303183e90792a5ef807933e88 /test/functional/api/rpc_fixture.lua | |
parent | 1b825a9ada4d89059645bc7a458e1e8d931c6161 (diff) | |
parent | 2d60a15e25f487eda1ac00a9e6cdf9a6564fb416 (diff) | |
download | rneovim-71b3e20d0fba20d4957c1949352bde1744a0a947.tar.gz rneovim-71b3e20d0fba20d4957c1949352bde1744a0a947.tar.bz2 rneovim-71b3e20d0fba20d4957c1949352bde1744a0a947.zip |
Merge pull request #4723 from bfredl/rpcstderr
allow stderr handler for rpc jobs and use it to display python/ruby startup error
Diffstat (limited to 'test/functional/api/rpc_fixture.lua')
-rw-r--r-- | test/functional/api/rpc_fixture.lua | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/test/functional/api/rpc_fixture.lua b/test/functional/api/rpc_fixture.lua new file mode 100644 index 0000000000..423864740f --- /dev/null +++ b/test/functional/api/rpc_fixture.lua @@ -0,0 +1,38 @@ +local deps_prefix = './.deps/usr' +if os.getenv('DEPS_PREFIX') then + deps_prefix = os.getenv('DEPS_PREFIX') +end + +package.path = deps_prefix .. '/share/lua/5.1/?.lua;' .. + deps_prefix .. '/share/lua/5.1/?/init.lua;' .. + package.path + +package.cpath = deps_prefix .. '/lib/lua/5.1/?.so;' .. + package.cpath + +local mpack = require('mpack') +local StdioStream = require('nvim.stdio_stream') +local Session = require('nvim.session') + +local stdio_stream = StdioStream.open() +local session = Session.new(stdio_stream) + +local function on_request(method, args) + if method == 'poll' then + return 'ok' + elseif method == 'write_stderr' then + io.stderr:write(args[1]) + return "done!" + elseif method == "exit" then + session:stop() + return mpack.NIL + end +end + +local function on_notification(event, args) + if event == 'ping' and #args == 0 then + session:notify("vim_eval", "rpcnotify(g:channel, 'pong')") + end +end + +session:run(on_request, on_notification) |