{ config, pkgs, lib, ... }: let myNeovim = (pkgs.neovim.override { configure = { inherit (config.vim) beforePlugins; customRC = with lib; (concatStringsSep "\n" (mapAttrsToList (variable: value: "let g:${variable} = ${value}") config.vim.variables)) + "\n" + builtins.readFile ../dotfiles/vimrc.vim + config.vim.extraConfig; vam = with pkgs; { pluginDictionaries = [ # UI { name = "undotree"; } { name = "gruvbox-community"; } { name = "gitgutter"; } { name = "lightline-vim"; } { name = "vim-dirvish"; } # Motions { name = "camelcasemotion"; } { name = "surround"; } { name = "targets-vim"; } # Frameworks { name = "deoplete-nvim"; } { name = "neosnippet"; } { name = "neosnippet-snippets"; } { name = "neoformat"; } { name = "ctrlp"; } # Syntax generic completion for deoplete { name = "neco-syntax"; } # Languages { name = "vim-polyglot"; } { name = "editorconfig-vim"; } # Vim completion for deoplete { name = "neco-vim"; } { name = "deoplete-zsh"; } { name = "vim-pandoc"; } { name = "vim-pandoc-syntax"; } # Languages (but not programming languages) { name = "vim-grammarous"; } # Other { name = "tmux-complete-vim"; } { name = "fugitive"; } { name = "rhubarb"; } { name = "repeat"; } { name = "vim-unimpaired"; } { name = "tabular"; } { name = "vimwiki"; } { name = "vim-abolish"; } ] ++ config.vim.extraPlugins; }; }; }); in { options.vim = with lib; { variables = mkOption { type = types.attrsOf types.str; default = { dominant_color = "'${config.theme.colors.dominant}'"; ripgrep_path = "'${pkgs.ripgrep}/bin/rg'"; fd_path = "'${pkgs.fd}/bin/fd'"; }; description = '' Extra global variables to add at the beginning of the vim configuration. Remember to escape strings with single-quotes. ''; }; extraPlugins = mkOption { type = types.listOf (types.attrsOf types.str); default = []; description = "Names of extra plugins to add"; }; extraRepoPlugins = mkOption { type = types.listOf (types.attrsOf types.str); default = []; description = "Names of extra plugins to add that are present in the local repository"; }; beforePlugins = mkOption { type = types.lines; default = ""; description = "Extra lines to add in the vim configuration before loading plugins"; }; extraConfig = mkOption { type = types.lines; default = ""; description = "Extra lines to add at the end of the vim configuration"; }; }; config = { environment.systemPackages = with pkgs; [ myNeovim ]; environment.sessionVariables = { EDITOR = "nvim"; }; home-manager.users.minijackson = { ... }: { xdg.dataFile."nvim/backup/.keep".text = ""; }; home-manager.users.root = { ... }: { xdg.dataFile."nvim/backup/.keep".text = ""; }; }; }