.NET client for Neovim
Using vim-plug:
Plug 'neovim/nvim.net'
- 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 test/NvimClient.Test/NvimClient.Test.csproj
- Create a new solution and class library project.
mkdir my-plugin dotnet new sln dotnet new classlib --output my-plugin dotnet sln add my-plugin/my-plugin.csproj
- Install the
NvimClient.API
NuGet packagedotnet add my-plugin/my-plugin.csproj package NvimClient.API
- Create a class like this
using NvimClient.API; using NvimClient.API.NvimPlugin.Attributes; using NvimClient.API.NvimPlugin.Parameters; namespace MyPlugin { // Make sure the class is public and has the NvimPlugin attribute. [NvimPlugin] public class MyPlugin { private readonly NvimAPI _nvim; // Constructor with exactly one `NvimAPI` parameter. public MyPlugin(NvimAPI nvim) { _nvim = nvim; } // Use attributes to expose functions, commands, and autocommands. // Valid parameter types and return types are: // string, bool, long, double, T[], and IDictionary<T, T> [NvimFunction] public long MyFunction(long num1, long num2) { return num1 + num2; } [NvimCommand(Range = ".", NArgs = "*")] public void MyCommand(long[] range, params object[] args) { _nvim.SetCurrentLine( $"Command with args: {args}, range: {range[0]}-{range[1]}"); } [NvimAutocmd("BufEnter", Pattern = "*.cs")] public void OnBufEnter( [NvimEval("expand('<afile>')")] string filename) { _nvim.OutWrite($"my-plugin is in '{filename}'\n"); } } }
- Make the directory
rplugin/dotnet
in the same directory as the solution file. If you are using git, you will need to create a file inside the directory so it can be tracked.mkdir rplugin/dotnet echo '' > rplugin/dotnet/.keep git add rplugin/dotnet
- Start
nvim
and run:UpdateRemotePlugins
.
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 test/NvimClient.Test/NvimClient.Test.csproj
Run only the TestMessageDeserialization
test:
dotnet test --filter TestMessageDeserialization test/NvimClient.Test/NvimClient.Test.csproj
- Update version as necessary in
src/NvimClient.API/NvimClient.API.csproj
. - Run the publish workflow.