.NET client for Neovim
- Install dotnet
- Clone the Nvim .NET client (this repo):
git clone https://github.com/neovim/nvim.net - Run the tests, to check that everything is working:
dotnet test --solution NvimClient.slnx
The following is a complete, working RPC module. It adds an :ExampleAdd
command that prints 3.
- From the repository root, create a console project and reference
NvimClient.API:dotnet new console --output NvimNetExample dotnet add NvimNetExample/NvimNetExample.csproj reference src/NvimClient.API/NvimClient.API.csproj cd NvimNetExample - Replace
Program.cswith:Standard output is the MessagePack RPC stream. Write diagnostics only to standard error.using System; using NvimClient.API; var nvim = NvimAPI.CreateFromStandardIO(); nvim.RegisterHandler( "example.add", args => (long)args[0] + (long)args[1] ); Console.Error.WriteLine("ready"); nvim.WaitForDisconnect();
- Publish the module:
dotnet publish --output publish
- Create
example.luain the project directory:local module_path = vim.fn.getcwd() .. "/publish/NvimNetExample.dll" local ready = false local channel = vim.fn.jobstart( { "dotnet", module_path }, { rpc = true, on_stderr = function(_, data) if vim.tbl_contains(data, "ready") then ready = true end end, } ) assert(channel > 0, "failed to start the .NET module") assert(vim.wait(5000, function() return ready end), "timed out waiting for the .NET module") vim.api.nvim_create_user_command("ExampleAdd", function() print(vim.fn.rpcrequest(channel, "example.add", 1, 2)) end, {})
- Start Neovim from the project directory and run
:ExampleAdd:nvim --clean -u example.lua
dotnet build
The API generator takes two arguments: the output path of the generated C# class
file and the path to the Neovim source directory. nvim and doxygen must be
in the PATH.
dotnet run --project src/NvimClient.APIGenerator/NvimClient.APIGenerator.csproj
src/NvimClient.API/NvimAPI.generated.cs
/usr/local/src/neovim/
Run all tests (nvim must be in the PATH):
dotnet test --solution NvimClient.slnx
- Update version as necessary in
src/NvimClient.API/NvimClient.API.csproj. - Ensure the repository secret
NUGET_API_KEYis set to a nuget.org API key with package push permission. No extra GitHub Packages secret is required; the workflow uses the built-inGITHUB_TOKEN. - Run the publish workflow
from the branch or tag to release. Leave
package-versionempty to use the project version, or set it to overridePackageVersionfor that run. - The workflow builds, packs, uploads the
.nupkgand.snupkgartifacts, then pushes the.nupkgpackages to GitHub Packages and nuget.org.