public static async Task RegisterPlugin(NvimAPI api, string pluginPath, Type pluginType) { var pluginAttribute = pluginType.GetCustomAttribute <NvimPluginAttribute>(); if (pluginAttribute == null) { throw new Exception( $"Type \"{pluginType}\" must have the NvimPlugin attribute"); } var pluginInstance = Activator.CreateInstance(pluginType, api); var methodsDictionary = new Dictionary <string, Dictionary <string, object> >(); var exports = GetPluginExports(pluginType, pluginPath, pluginInstance) .ToArray(); foreach (var export in exports) { export.Register(api); if (export is NvimPluginFunction function) { methodsDictionary[function.Name] = new Dictionary <string, object> { { "async", !function.Sync }, { "nargs", function.Method.GetParameters().Length } }; } } await RegisterPlugin(api, pluginPath, exports); var version = new Version(pluginAttribute.Version); await api.SetClientInfo(pluginAttribute.Name ?? pluginType.Name, new Dictionary <string, int> { { "major", version.Major }, { "minor", version.Minor }, { "patch", version.Build } }, "plugin", methodsDictionary, new Dictionary <string, string> { { "website", pluginAttribute.Website }, { "license", pluginAttribute.License }, { "logo", pluginAttribute.Logo } }); var channelID = (long)(await api.GetApiInfo())[0]; await api.CallFunction("remote#host#Register", new object[] { PluginHostName, "*", channelID }); }
public async Task TestLocalSocket() { var nvimStdio = new NvimAPI(); var serverAddress = (string)await nvimStdio.CallFunction("serverstart", new object[0]); var nvimLocalSocket = new NvimAPI(serverAddress); Assert.IsNotNull(await nvimLocalSocket.CommandOutput("version")); }
private static async Task RegisterPlugin(NvimAPI api, string pluginPath, IEnumerable <NvimPluginExport> exports) { await api.CallFunction("remote#host#RegisterPlugin", new object[] { PluginHostName, pluginPath, exports.Select(export => export.GetSpec()).ToArray() }); }
public async Task TestTCPSocket() { var nvimStdio = new NvimAPI(); var serverAddress = (string)await nvimStdio.CallFunction("serverstart", new object[] { System.Net.IPAddress.Loopback + ":" }); var nvimTCPSocket = new NvimAPI(serverAddress); Assert.IsNotNull(await nvimTCPSocket.CommandOutput("version")); }