Closed ajayvigneshk closed 1 year ago
This might be as simple as implementing a subset of the JSON encoding ourselves. Encoding seems to be fairly straightforward: https://github.com/cblage/elixir-json/blob/master/lib/json/encoder/default_implementations.ex
Yeah perhaps. Just that writing our own JSON encoder seems way further from the actual project's scope of being a neovim test framework (not to forget the extra maintenance due to it)
Mix.install
looks interesting (yet to try it out though)
I tried embedding Poison (as it has fewer files) but the command takes 25 seconds compiling every time before running the tests. It's probably the protocols.
Embedding a version that doesn't use protocols is an option, but I agree that is further from the scope of the library.
I'm sure Mix.install
would work in a completely independent file, but we would have to test how it behaves when you then run a project after requiring the script.
Basically, we need a way to transfer the following structure to Lua:
%{
id: "some id with potentially special chars",
status: "simple string",
output: "/some/file/path" or nil,
errors: [
%{
message: "some text with potentially special chars",
line: number or nil
}
]
}
With #3 the special chars in the id would be removed, assuming files don't have anything weird, and I guess the errors could be saved to files and read on the Neovim side.
If we don't have to worry much about escaping characters, then it becomes easier.
Adding Mix.install
makes it fail like this:
The actual error is this
%Mix.Error{message: "Mix.install/2 cannot be used inside a Mix project", mix: 1}
Which makes sense, since the formatter is invoked in the same context as the mix project.
Am thinking if we can split the formatter into two GenServers,
Seems like overkill, but I can't think of any other option. I'm not sure if there would be any negative implications due to this
If both instances are nodes then we can connect them and use remote calls for communication but that also adds more complexity and then the embeded encoder option doesn't sound so bad xD
I tried implementing the encoder without protocols and it takes less than 70 lines: https://github.com/jfpedroza/neotest-elixir/blob/jp/embedded-json-encoder/neotest_elixir/json_encoder.exs
Yeah that seems good and apt!
Creating an issue from the TODO item to have discussion
I explored if using the ETF format could be an option. There exists a lua parser for it. But sadly this seems to make use of lua 5.3 constructs which is very hard to get it working on neovim (lua 5.1). More specifically, the parser uses
<<
which seems to be supported under a different module / syntax refstring.unpack
function for which all the existing options falls short in different waysCurious if there are any other ways / options to achive this