dart_nvim_api 0.1.4

  • Readme
  • Changelog
  • Example
  • Installing
  • 57

Build Status Pub

Dart Nvim API #

Neovim API implementation for Dart, based on and inspired by neovim-lib. Still a WIP, so any feedback, contributions, etc. are greatly appreciated.

Example Usage #

import 'package:dart_nvim_api/dart_nvim_api.dart';

main(List<String> args) async {
  // Start up Neovim instance and communicate over stdin/stdout:
  var nvim = Neovim(nvimBinaryPath: 'nvim');

  // Or connect to already running instance over TCP:
  // var nvim = Neovim.connectToRunningInstance(host: '127.0.0.1', port: 8888);

  // Run Neovim ex command.
  await nvim.command("echo 'hello'");

  // Get ex command output.
  assert(await nvim.commandOutput("echo 'hello'") == null);

  // Buffer example:
  var buf = await nvim.createBuf(true, false);
  var bufNum = await buf.getNumber(nvim);
  assert(bufNum == 2);
  assert(await nvim.getCurrentBuf() is Buffer);

  // Beyond that, you can run any Neovim api command. See `:help api-rpc` doc in Neovim.
  // See also `example` directory.
}

Contributing #

Changes to the Neovim, Window, Buffer, and Tabpage classes should be done in the template files in the gen_bindings/src folder. To generate lib/src/*.dart do the following from the project root (requires pip in addition to python v3.7.4. Note that older versions of Python 3 may work, I just haven't tested them):

$ pip install -g datetime jinja2
# Replacing <nvim binary path> as necessary:
$ python gen_bindings/gen_bindings.py <nvim binary path> 'lib/src' 'gen_bindings/src/'

Changes to any other files can be done as usual.

0.1.0 #

  • Initial version

0.1.1 #

  • Make function names for the Buffer, Tabpage, and Window classes camelcase.
  • Fix an issue where API functions which were supposed to return a Buffer, Tabpage, or Window would return null instead.

0.1.2 #

  • Additions
    • attachUi function in the Neovim class for attaching an external UI to Neovim.
    • Travis.
    • Documentation for Neovim class (not finished yet, mainly waiting on neovim/neovim#1139 and a subsequent PR adding a way to get the documentation on each API function from Neovim).
    • Classes for each type of ui_event from Neovim.
    • example directory with a short example (shown in README).
  • Changes
    • Moved Neovim class from lib/dart_nvim_api.dart to lib/src/neovim.dart to be more consistent with idiomatic Dart library structure.
    • Updated README to show latest library version from pub.dev

0.1.3 #

  • Added Session.fromCurrentStdinStdout() function and an optional flag (communicateWithParentProcess) to the Neovim class (see docs for more info).

0.1.4 #

  • Fixed an issue where functions which returned Lists (e.g. Buffer().getLines would throw an error saying type 'List<dynamic>' is not a subtype of type 'List<String>' in type cast or similar.

example/example.dart

import 'package:dart_nvim_api/dart_nvim_api.dart';

main(List<String> args) async {
  // Start up Neovim instance and communicate over stdin/stdout:
  var nvim = Neovim(nvimBinaryPath: 'nvim');

  // Or connect to already running instance over TCP:
  // var nvim = Neovim.connectToRunningInstance(host: '127.0.0.1', port: 8888);

  // Run Neovim ex command.
  await nvim.command("echo 'hello'");

  // Get ex command output.
  assert(await nvim.commandOutput("echo 'hello'") == null);

  // Buffer example:
  var buf = await nvim.createBuf(true, false);
  var bufNum = await buf.getNumber(nvim);
  assert(bufNum == 2);
  assert(await nvim.getCurrentBuf() is Buffer);

  // Beyond that, you can run any Neovim api command. See `:help api-rpc` doc in Neovim.
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  dart_nvim_api: ^0.1.4

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:dart_nvim_api/dart_nvim_api.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
16
Health:
Code health derived from static analysis. [more]
96
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
57
Learn more about scoring.

We analyzed this package on Apr 8, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.6

Health suggestions

Fix lib/src/window.dart. (-4.41 points)

Analysis of lib/src/window.dart reported 9 hints, including:

line 11 col 18: This function has a return type of 'Future

line 24 col 21: This function has a return type of 'Future<List

line 37 col 15: This function has a return type of 'Future

line 50 col 15: This function has a return type of 'Future

line 92 col 21: This function has a return type of 'Future<List

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.5.0 <3.0.0
meta ^1.1.7 1.1.8
msgpack_dart ^0.0.6 0.0.7
Dev dependencies
pedantic ^1.8.0
test ^1.6.0