Skip to content

rafleon/neovim-pool

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Neovim Pool

The Problem

In neovim, some LSP servers for some projects can take significant time to start before they are usable.

The Solution

These scripts solve the problem by maintaining a rotating pool of neovim servers. Each neovim process in the pool maintains connections to attached LSP servers.

On startup, neovim automatically creates control sockets in the /run/user/$UID directory. You can use these sockets to control neovim processes. If you start a headless neovim, it creates one of these control sockets. You can then attach and detach from the server process, leaving the server intact. The neovim server maintains its connections to any attached LSP servers. This is the key.

This project currently consists of two files: a shell script and a Lua init file.

The shell script maintains the neovim server pool. If an existing neovim server is idle with no UI connections, the client script simply attaches to it. If no servers are available, the script creates a new one and then attaches to it.

On creation of a new neovim server, a custom Lua init script is loaded. This init script will load after your existing init.lua and all other config. This init overrides the default bindings for :q and :wq to call detach instead of quit. It doesn't override anything else. :quit and :exit will still terminate the neovim server and kill the LSP. If your muscle memory uses :x, then you will need to alter the overrides.

Installation

  1. Install neovim
  2. Clone this repo.
  3. Put this repo on your $PATH
  4. alias vi="neovim-pool.sh"
  5. Customize as you wish

TODO

  • Add better installation methods.
  • Attach to servers based on LSP root directories instead of randomly.
  • Add Neovide support.

Inspiration

This project was inpired by nvim-unception.

About

Scripts to maintain and use a pool of Neovim servers.

Topics

Resources

License

Stars

Watchers

Forks