nvim-rs
nvim-rs copied to clipboard
Hide Value from user and use serde instead
In your thoughts that you posted I saw that you wanted a strongly typed api and to hide Value
from the user. I have implemented that using rmp_serde
and the with_serde
feature flag of rmpv
. This allows send_msg
to send anything with args that implement Serialize
opening up possibilities for a strongly typed api because using structs as args
will also work. This way call
and call_function
can both take a wide range of values also. The base of this pr is implementing Serialize
and Deserialize
for RpcMessage
. Before you were manually serializing and deserializing into RpcMessage
. Instead I have implemented the serde traits which is much easier and fits into the serde data model. Eventually I think that we don't need Value
at all and can just rely on serde
. This pr can open up very cool possibilities like having custom structs for common things like CompleteItems
and QfListItems
.
Licensing: The code contributed to nvim-rs is licensed under the MIT or Apache license as given in the project root directory.
Hey sorry for leaving this open so long, I have a hard time finding time for this project. I think I can work at it again real soon, but first I'll need to do chores I guess (CI...), so it might still need some time. Especially seeing this is somewhat complicated for me :)
I'm a bit hesitating anyways, since it adds serde as a dependency, and I'm not yet sure if that's really pulling it's weight. But that strongly typed API and custom structs really are enticing!
Its okay, I was working on a larger pr after I submitted this one by I lost interest. However, I do think it is very nice because then all functions can take a serde trait bound allowing for very expressive calling of functions.
So I'll be putting in some inline questions for @smolck who wants to take over here.
Maybe it would be far simpler to abstract Value
to impl Into<Value>
. If Value
is provided it will be no-op anyways.
That might just be feasible as well :)
That might just be feasible as well :)
So I tried to manually do it then realized the code is generated, in generated code, I have gotten away with code_data: code_data.into()
but for the rest I couldn't understand how to do it with the template
Not all is generated, have a look at https://github.com/KillTheMule/nvim-rs/blob/master/src/neovim_api_manual.rs. If we figure out something good, changing the generating script can follow.
This branch has conflicts that must be resolved