Skip to content

fmoralesc/nvimfs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 

Repository files navigation

nvimfs

A FUSE filesystem that exposes the Neovim API.

Dependencies

  • FUSE
  • Neovim
  • Python 3 (tested using 3.4)
  • python-neovim for Python 3 (pip3 install neovim)

Setup

First, install in your 'runtimepath'. Using a plugin manager like vim-plug, you need to add this to your vimrc:

Plug 'fmoralesc/nvimfs'

and then execute

:PlugInstall

to download and install the plugin. Afterwards, register the remote plugin with

:UpdateRemotePlugins

and finally, restart Neovim.

Usage

The nvim filesystem will be mounted by default on &rtp[0] (typically, ~/.nvim/), under the neovimfs folder.

The typical tree will look like this:

neovimfs/
└── clients
    ├── 0
    │   ├── buffers
    │   │   ├── 1
    │   │   │   ├── name
    │   │   │   └── tags
    │   │   ├── 2
    │   │   │   ├── name
    │   │   │   └── tags
    │   │   └── new
    │   ├── cmd
    │   ├── eval
    │   ├── name
    │   └── windows
    │       └── new
    └── new

As you can see, at the toplevel there is the clients/ directory. In it there is a file called new, and a series of numbered directories, each representing a neovim client. To register a new client, you can write the path to the client socket to the new file, which will initialize the corresponding subdirectory (the plugin does this automatically for every new client).

The filesystem won't be unmounted when any particular neovim instance exists, and the plugin will try to manage it so its contents are in sync with the running neovim instances. This means it can be used to manage several neovim instances at once: for example, to query if any instance is editing a file matching buffer.py, you can use the typical unix tools:

    $ cd clients/
    $ grep -r "buffer.py" . --exclude new
    ./2/buffers/10/name:/home/felipe/devel/project/dir/buffer.py
    ./3/buffers/2/name:/home/felipe/devel/toy/newbuffer.py

You can send commands to the running nvim instances by writing to the cmd file:

    $ echo "e /tmp" > clients/0/cmd

You can also evaluate expressions:

    $ echo "has('nvim')" > clients/0/eval
    $ cat clients/0/eval
    1

Note: multiple lines can be written to the eval file, so you can use it as a scratch buffer from within Neovim. You can also append new expressions to the file:

    $ echo "1+1" >> clients/0/eval
    $ cat clients/0/eval
    1
    2

About

FUSE filesystem that talks the Neovim API

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages