Neovim Flake by Gabriel Volpe


1. Try it out
1.1. Binary cache
1.2. Scala
1.3. Haskell
2. Home Manager
2.1. Packages
2.2. Configuration files
A. Configuration options

Chapter 1. Try it out

$ nix run github:gvolpe/neovim-flake

By default, LSP support is enabled for Scala, Dhall, Elm, Nix, and Smithy.

1.1. Binary cache

To save you CPU resources and time, you can add the following binary cache to your ~/.config/nix/nix.conf:

substituters = https://cache.garnix.io
trusted-public-keys = cache.garnix.io:CTFPyKSLcx5RMJKfLo5EEPUObbA78b0YQ2DTCJXqr9g=

1.2. Scala

Those only interested in Scala LSP support can try the more lightweight versions.

$ nix run github:gvolpe/neovim-flake#scala
$ nix run github:gvolpe/neovim-flake#scala-rose-pine
$ nix run github:gvolpe/neovim-flake#scala-tokyo-night

The default theme is onedark with transparency enabled, but there are other flavors.

You may also try Neovim nightly version.

$ nix run github:gvolpe/neovim-flake#scala-nightly

1.3. Haskell

Those only interested in Haskell LSP support can try the exclusive version.

$ nix run github:gvolpe/neovim-flake#haskell

Haskell LSP requires a lot of packages, so expect a heavy build or download if you are leveraging the binary cache. For this reason, Haskell is disabled in the default IDE configuration.

Chapter 2. Home Manager

The Home Manager module allows us to customize the different vim options. To use it, we first add the input flake.

{
  neovim-flake = {
    url = github:gvolpe/neovim-flake;
    inputs.nixpkgs.follows = "nixpkgs";
  };
}

Followed by importing the HM module.

{
  imports = [ neovim-flake.homeManagerModules.default ];
}

Then we should be able to use the given module. E.g.

{
  programs.neovim-ide = {
    enable = true;
    settings = {
      vim.viAlias = false;
      vim.vimAlias = true;
      vim.lsp = {
        enable = true;
      };
    };
  };
}

Besides the classic Appendix A, Configuration options, you can also use the searchable module options.

For the Scala module, the metals binary can be easily overridden with the provided builder. E.g.

{
  vim.lsp = {
    enable = true;
    scala = {
      enable = true;
      metals = {
        package = pkgs.metalsBuilder {
          version = "0.11.8+76-22425a8b-SNAPSHOT";
          outputHash = "[Insert hash (try nix build .#)]";
        };
        serverProperties = [
          "-Dmetals.enable-best-effort=true"
          "-Xmx2G"
          "-XX:+UseZGC"
        ];
      };
    };
  };
}

It enables the featureful and recommended nvim-metals.

Note

To use metalsBuilder, you need to add the following overlay.

{
  pkgs = import nixpkgs {
    inherit system;
    overlays = [ neovim-flake.overlays.default ];
  };
}

You can have a look at my nix-config for a full example.

2.1. Packages

Besides the full-fledged IDE and HM modules, there are a few packages exposed that may prove useful to your use case.

  • ts-scala: tree-sitter-scala version that tracks the latest master changes.
  • nvim-treesitter: latest nvim-treesitter ensuring compatibility with tree-sitter-scala.

If you have your own NeoVim configuration, you can still leverage nvim-treesitter by first adding the overlay, and then using the following package.

{
  programs.neovim = {
    enable = true;
    plugins = [
      pkgs.neovimPlugins.nvim-treesitter
    ];
  };
}

Or more directly without the overlay.

{
  programs.neovim = {
    enable = true;
    plugins = [
      inputs.neovim-flake.packages.${system}.nvim-treesitter
    ];
  };
}

You can see all the enabled grammars for this package here.

The ts-scala package only builds tree-sitter-scala from master, but it wouldn’t be as useful for your own configuration because nvim-treesitter requires a few tweaks.

2.2. Configuration files

Furthermore, the generated neovimRC and luaRC files for every flavor of Neovim exposed by this flake are also available as derivations for better visibility.

  • ide-lua-rc
  • ide-neovim-rc
  • haskell-lua-rc
  • haskell-neovim-rc
  • scala-lua-rc
  • scala-neovim-rc

These could also be useful to debug when plugins don’t work as expected.