nvimhost 1.0.0
Nvim (neovim) host provider and API client library.
To use this package, run the following command in your project's root directory:
Manual usage
Put the following dependency into your project's dependences section:
nvimhost-d
Neovim (nvim) host provider and API client library written in D.
Docs
The following snippets show how you can use this library, check out the exaples for more information:
Plugin snippet demo
import nvimhost.plugin;
import nvimhost.api;
struct DemoPlugin {
NvimAPI nvim;
this(ref NvimAPI nvim) {
this.nvim = nvim;
}
// sync function with one argument
@NvimFunc("Greet")
string greet(string name) {
return "Hello " ~ name;
}
// sync function with multiple arguments
@NvimFunc("SumBeginToEnd")
int sumBeginToEnd(int begin, int end) {
import std.range;
import std.algorithm.iteration;
import std.stdio;
return cast(int) iota(begin, end).sum();
}
// sync function calling async (non blocking) nvim functions
@NvimFunc("SetVarValueSync")
int setVarValue(int i) {
import std.conv;
nvim.commandAsync("let g:test_var_value=" ~ i.to!string);
return i;
}
// async function calling both async and sync nvim functions
@NvimFunc("SetVarValueAsync", Async)
void setVarValueAsync(int i) {
import std.conv;
nvim.commandAsync("let g:testasync_var_value=" ~ i.to!string);
nvim.command("echomsg 'hello world sync!'");
}
}
void main() {
// make sure you source this .vim file in neovim, since this will bootstrap
// the binary and register the plugin
auto pluginDstFile = "~/.config/nvim/settings/demo-plugin.vim";
// template instantiate DemoPlugin
auto plugin = NvimPlugin!(DemoPlugin)("demo-plugin", pluginDstFile);
// keep it running
scope (exit) {
plugin.keepRunning();
}
}
API client snippet demo
void main() {
import std.stdio;
import nvimhost.api : NvimAPI;
auto nvim = NvimAPI();
nvim.enableLog();
// Calling a simple command on Neovim
nvim.command("echomsg 'hello world!'");
// Iterating over loaded buffers
auto buffers = nvim.vimGetBuffers();
foreach (buffer; buffers) {
writeln("buffer #", buffer);
}
}
Install
- Simply fetch it using
dub
. Whenever you import a module from thenvimhost
package, it'll be built as a library by default.
dub fetch nvimhost
dub build --build=release
Testing
Unit tests
dub test
System tests
python -m pytest system_tests
- Registered by Vinicius Arcanjo
- 1.0.0 released 5 years ago
- viniarck/nvimhost-d
- Apache
- Copyright © 2018, Vinicius S. Arcanjo
- Authors:
- Dependencies:
- msgpack-d, vibe-core
- Versions:
-
1.1.1 2019-Jan-08 1.1.0 2019-Jan-06 1.0.0 2018-Dec-31 ~master 2020-Nov-12 - Download Stats:
-
-
0 downloads today
-
0 downloads this week
-
0 downloads this month
-
17 downloads total
-
- Score:
- 0.9
- Short URL:
- nvimhost.dub.pm