nvim.net


Ⅰ. 插件描述

Nvim .NET client and plugin host

Ⅱ. 基本信息

创建日期:  2018-05-15
使用用户:  1
Github星:  19
插件作者:  Neovim

Ⅲ. 安装方法

使用Vundle管理器安装

在你的.vimrc下添加:
Plugin 'neovim/nvim-net'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall

对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。

使用NeoBundle管理器安装

在你的.vimrc下添加:
NeoBundle 'neovim/nvim-net'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall

使用VimPlug管理器安装

在你的.vimrc下添加:
Plug 'neovim/nvim-net'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall

使用Pathogen管理器安装

在终端中运行以下命令:
cd ~/.vim/bundle
git clone https://github.com/neovim/nvim.net

Ⅳ. 文档说明

Nvim.NET

AppVeyor Build status
Travis Build Status

.NET client for Neovim

Plugin Host Install

Using vim-plug:

Plug 'neovim/nvim.net'

Quickstart for Linux

  1. Install dotnet
  2. Clone the Nvim .NET client (this repo):

    git clone https://github.com/neovim/nvim.net
  3. Run the tests, to check that everything is working:

    dotnet test test/NvimClient.Test/NvimClient.Test.csproj

Plugin Development with C

  1. 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
  2. Install the NvimClient.API NuGet package

    dotnet add my-plugin/my-plugin.csproj package NvimClient.API
  3. 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");
        }
      }
    }
  4. 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
  1. Start nvim and run :UpdateRemotePlugins.

Build

dotnet build

Generate API

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/

Test

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

添加新评论