Nix flake for neovim with configuration options
Originally based on Jordan Isaacs' amazing neovim-flake
$ cachix use gvolpe-nixos # Optional: this will save you CPU resources
$ nix run github:gvolpe/neovim-flake#
By default, Scala, Dhall, Elm, Nix, Haskell, and SQL lsp servers are enabled.
First of all, we add the input flake.
{
neovim-flake = {
url = github:gvolpe/neovim-flake;
inputs.nixpkgs.follows = "nixpkgs";
};
}
Followed by importing the HM module.
{
imports = [ neovim-flake.nixosModules.hm ];
}
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;
};
};
};
}
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 = pkgs.metalsBuilder {
version = "0.11.8+76-22425a8b-SNAPSHOT";
outputHash = "[Insert hash (try nix build .#)]";
};
type = "nvim-metals"; # or nvim-lspconfig
};
};
}
We can also choose to use the minimal configuration via nvim-lspconfig
or use the more featureful nvim-metals (default and recommended).
Have a look at my nix-config for a full example.
The philosophy behind this flake configuration is sensible options. While the default package has almost everything enabled, when building your own config using the overlay everything is disabled. By enabling a plugin or language, it will set up the keybindings and plugin automatically. Additionally each plugin knows when another plugin is enabled allowing for smart configuration of keybindings and automatic setup of things like completion sources and languages.
A goal of mine is that I shouldn't not be able to break neovim by enabling or disabling an option. For example you can't have two completion plugins enabled as the option is an enum.
Most languages use nvim-lspconfig to set up language server. Additionally some languages also (or exclusively) use null-ls to extend capabilities.
LSP Server: rnix-lsp
Formatting
rnix provides builtin formatting with nixpkgs-fmt.
LSP Server: elmls
LSP Server: hls
LSP Server: metals
Formatting
Metals provides builtin formatting with scalafmt.
Plugins
- nvim-metals enhances the metals experience.
LSP Server: dhall-lsp-server
LSP Server: sqls
Formatting
sqls provides formatting but it does not work very well so it is disabled. Instead using sqlfluff through null-ls.
Linting
Using sqlfluff through null-ls to provide linting diagnostics set at information
severity.
Plugins
- sqls.nvim for useful actions that leverage
sqls
LSP
LSP Server: rust-analyzer
Formatting
Rust analyzer provides builtin formatting with rustfmt
Plugins
LSP Server: ccls
LSP Server: typescript-language-server
Linting
Using eslint through null-ls.
Formatting
Disabled lsp server formatting, using prettier through null-ls.
LSP Server: pyright
Formatting:
Using black through null-ls
Plugins
- glow.nvim for preview directly in neovim buffer
Plugins
- nvim-ts-autotag for autoclosing and renaming html tags. Works with html, tsx, vue, svelte, and php
A list of all plugins that can be enabled
- nvim-lspconfig common configurations for built-in language server
- null-ls.nvim neovim as a language server to inject LSP diagnostics, code actions, etc.
- lspsaga.nvim useful UI and tools for lsp
- trouble.nvim pretty list of lsp data
- nvim-code-action-menu a better code action menu with diff support
- lsp-signature show function signatures as you type
- lspkind-nvim for pictograms in lsp (with support for nvim-cmp)
- nvim-bufferline-lua a buffer line with tab integration
- bufdelete-nvim delete buffers without losing window layout
- kommentary comment text in and out, written in lua
- nerdcommenter comment functions so powerful—no comment necessary
- todo-comments highlight, list and search todo comments
- lualine.nvim statusline written in lua.
- nvim-tree-lua a file explorer tree written in lua. Using
- gitsigns.nvim a variety of git decorations
- Nix installation of treesitter
- nvim-treesitter-context a context bar using tree-sitter
- nvim-ts-autotag uses treesitter to autoclose/rename html tags
- indent-blankline for indentation guides
- nvim-web-devicons Plugins and colors for icons. Requires patched font
- telescope an extendable fuzzy finder of lists. Working ripgrep and fd
- which-key a popup that displays possible keybindings of command being typed
- glow.nvim a markdown preview directly in neovim using glow
- nvim-compe A deprecated autocomplete plugin
- nvim-cmp a completion engine that utilizes sources (replaces nvim-compe)
- cmp-buffer a source for buffer words
- cmp-nvim-lsp a source for builtin LSP client
- cmp-vsnip a source for vim-vsnip autocomplete
- cmp-path a source for path autocomplete
- cmp-treesitter treesitter nodes autcomplete
- crates.nvim autocompletion of rust crate versions in
cargo.toml
- vim-vsnip a snippet plugin that supports LSP/VSCode's snippet format
- nvim-autopairs an autopair plugin for neovim
- onedark a dark colorscheme with multiple options
- nightfox a highly customizable theme with treesitter support
- tokyonight-nvim a neovim theme with multiple color options
- nvim-ufo enhance "ultra fold" experience for neovim
- plenary which is a dependency of some plugins, installed automatically if needed
- promise-async a dependency of nvim-ufo