-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
outputStream(p: Process) in osproc in standard library cannot call peekChar #58
Comments
this is not msgpack4nim problem, it's stdlib problem. |
I want to make a program that repeats sending a request message to neovim and receiving a response using msgpack-rpc through pipe. According to spec of msgpack and msgpack-rpc, it seems there is no way to get size of a whole message by reading only first fixed size bytes. That is why I wanted to pass output stream of neovim process to I have created new issue about it on Nim repository. |
I added I still don't think I can take message as string from pipe while the process is running. Here is working sample code to run neovim and send neovim command from Nim. import osproc, streams
import msgpack4nim, macros
macro writeRPCReq[ByteStream](
s: ByteStream;
methodName: string;
id: int;
args: varargs[typed]) =
let
argsLen = args.len.newLit
result = quote do:
`s`.pack_array 4
`s`.pack_type 0
`s`.pack_type `id`
`s`.pack_type `methodName`
`s`.pack_array `argsLen`
for a in args:
result.add newCall(bindSym"pack", s, a)
proc main =
var
p = startProcess("nvim", args = ["--embed"], options = {poUsePath})
inStrm = p.inputStream
outStrm = p.peekableOutputStream
stdoutStrm = stdout.newFileStream
var msgId = 0
for l in stdin.lines:
if not p.running:
break
inStrm.writeRPCReq("nvim_command_output", msgId, l)
inStrm.flush()
outStrm.stringify stdoutStrm.Stream
echo ""
inc msgId
p.close()
main() |
fixes #58, add export marker to stringify[ByteStream]
Thank you! |
I tried to send a command to neovim and receive a response using msgpack-rpc.
I added
*
toproc stringify[ByteStream](s: ByteStream, zz: ByteStream)
in msgpack4nim.nim and tried to output stringified response from neovim to stdout.But I got runtime error as
Stream
returned fromproc outputStream(p: Process): Stream
doesn't havepeekDataImpl
on windows.Should
peekDataImpl
be implemented forproc outputStream(p: Process): Stream
?Or msgpack4nim should not use peek?
I don't know this code sends request message to neovim correctly.
The text was updated successfully, but these errors were encountered: