robin/laufey

git clone https://git.robinwobin.dev/robin/laufey

Lewis Russelltest: run Lua harness with nvim -l9432e6c1e2

master
813 B32 linesraw
1--- RPC server fixture.
2--
3-- Lua's paths are passed as arguments to reflect the path in the test itself.
4package.path = arg[1]
5package.cpath = arg[2]
6
7local StdioStream = require 'test.client.uv_stream'.StdioStream
8local Session = require 'test.client.session'
9
10local stdio_stream = StdioStream.open()
11local session = Session.new(stdio_stream)
12
13local function on_request(method, args)
14  if method == 'poll' then
15    return 'ok'
16  elseif method == 'write_stderr' then
17    io.stderr:write(args[1])
18    return 'done!'
19  elseif method == 'exit' then
20    session:stop()
21    return vim.NIL
22  end
23end
24
25local function on_notification(event, args)
26  if event == 'ping' and #args == 0 then
27    session:notify('nvim_eval', "rpcnotify(g:channel, 'pong')")
28  end
29end
30
31session:run(on_request, on_notification)
32session:close()