write plugins for Neovim using Elixir
Clone or download
Type Name Latest commit message Commit time
Failed to load latest commit information.
config init POC version Aug 24, 2016
installer up version Mar 15, 2017
lib generate template with new syntax Jun 29, 2017
.travis.yml run integration suite on CI Nov 6, 2016
README.md up version Mar 15, 2017
mix.exs up version Mar 15, 2017
mix.lock Updating Elixir version to 1.4.0 and correcting syntax warnings. Mar 15, 2017


Neovim Elixir host Build Status

Implements support for Neovim remote plugins written in Elixir.


  • Neovim >= 1.6-dev
  • Elixir >= 1.3


Install the host archive, we will use it to build the host locally.

$ mix archive.install https://github.com/dm1try/nvim/releases/download/v0.4.2/nvim.ez

Build and install the host by running nvim.install and providing the path to nvim config(~/.config/nvim by default on linux systems)

$ mix nvim.install /path/to/nvim/config


Same as the install step but if you have any problem try to remove the host at first:

mix nvim.remove /path/to/nvim/config
mix nvim.install /path/to/nvim/config


Currently, each time you somehow update remote plugins you should run :UpdateElixirPlugins nvim command.

See :h remote-plugin-manifest for the clarification why the manifest is needed(generally, it saves the neovim startup time if remote plugins are installed).

Plugin Development (Developers only)

+--------+ MsgPack |              +---------+ |
|        |   RPC   | +------+     |         | |
| Neovim <---------> | Host <-----> Plugins | |
|        |         | +------+     |         | |
+--------+         |              +---------+ |


Host supports two types of plugins:

  1. Scripts (an elixir script that usually contains simple logic and does not depend on other libs/does not need the versioning/etc).

  2. Applications (an OTP application that is implemented as part of host umbrella project). You can find more information about umbrella projects here.

Host with plugins lives in rplugin/elixir neovim config directory. Script plugin name must have postfix plugin in his name.

Example my_plugin.exs

Typical files tree for such dir:


├── scripts <~ scripts
├── apps <~ applications AKA "precompiled plugins"
└── mix.exs

Plugin DSL


on_event(better known as autocmd for vim users) defines the callback that triggered by editor when some event happened. Run :h autocmd-events for the list of events.

on_event :vim_enter do
  Logger.info("the editor is ready")


function defines the vim function

function wrong_sum(left, right) do
  left - right

use it in the editor :echo WrongSum(1,2)


command defines the command.

command just_echo do
  NVim.Session.nvim_command("echo 'from remote plugin'")

use it in the editor :JustEcho

Only single param can be defined for a command. This param holds an array of strings provided on the command call. Elixir OptionParser is good choice here.


In the latest example we used nvim_command method which is part of Neovim remote API. In the examples below we asume that we import NVim.Session in context of plugin.


Each plugin is GenServer. So you can share the state between all actions while the plugin is running:

def init(_args) do
  {:ok, %{move_count: 0}}

on_event :cursor_moved do
  state = %{state | move_count: state.move_count + 1}

command show_moves_count do
  moves_info = "Current moves: #{state.move_count}"
  nvim_command("echo '#{moves_info}'")

NOTE: you cannot assing the state in inner scopes(if/case/with/etc). You should return the value from the scope and then assing it to the state in root scope.

Pre-evaluated values

Any vim value can be pre-evaluated before the action will be triggered:

on_event :cursor_hold_i,
  pre_evaluate: %{
    "expand('cWORD')" => word_under_cursor
  if word_under_cursor == "Elixir" do

Basic scripts

"Hello" from plug:

# ~/.config/nvim/rplugin/elixir/scripts/my_plugin.exs
defmodule MyPlug do
  use NVim.Plugin

  command hello_from_plug do
    NVim.Session.nvim_command "echo 'hello'"

Debugging scripts.

ElixirHostLog opens the host log. Log severety level can be changed in the host config.

~/.config/nvim/rplugin/elixir/apps/host/config/config.exs is default path on linux

ElixirReloadScript reloads running script.

This works only for the reloading an implementation of already defined command/function/event. This means if you add/remove some definition or change its option(pre_evaluate for example) you should restart the editor.