Neovim (nvim-lspconfig)

../../_images/nvim-lspconfig.png

Using esbonio with Neovim’s built in language client

This guide covers how to setup esbonio with Neovim’s built-in language client.

Installation

The language server can be installed using pip, or if you prefer, conda.



Configuration

Basic configuration for the language server is available through the nvim-lspconfig plugin.

Configuration settings are provided via the settings table passed to lspconfig.esbonio.setup {}. Perhaps the most important setting is esbonio.sphinx.pythonCommand (string[]) which tells the server which Python envrionment to use when building your documentation.

Another important setting is esbonio.sphinx.buildCommand (string[]) which tells the server the command you use to build your documentation.

lspconfig.esbonio.setup {
  settings = {
    sphinx = {
      pythonCommand = { "/path/to/project/.venv/bin/python" },
      buildCommand = { "sphinx-build", "-M", "html", "docs", "docs/_build" },
    }
}

See Configuration for a complete reference of all configuration options supported by the server.

Examples

Do you use Nix?

If you have the Nix package manager on your machine you can try out our example configuration with the following command:

nix run github:swyddfa/esbonio/beta#nvim-lspconfig

To try the example configuration on your machine.

  1. Download init.vim to a folder of your choosing.

  2. Ensure you have the nvim-lspconfig plugin installed.

  3. Open a terminal in the directory containing this file and run the following command to load this config isolated from your existing configuration:

    nvim -u init.vim
    

Troubleshooting

You will also have to increase the LSP logging level in Neovim itself.

lua << EOF
vim.lsp.set_log_level("debug")
EOF

You can then open the log file with the command :LspLog. See here for more details.