From a2439e94194b47bf56ea4b37a33096953b336a3c Mon Sep 17 00:00:00 2001 From: Gabriel Arazas Date: Fri, 9 Aug 2024 15:20:47 +0800 Subject: [PATCH] wrapper-manager/programs/neovim: init --- modules/wrapper-manager/default.nix | 1 + modules/wrapper-manager/programs/neovim.nix | 112 ++++++++++++++++++++ 2 files changed, 113 insertions(+) create mode 100644 modules/wrapper-manager/programs/neovim.nix diff --git a/modules/wrapper-manager/default.nix b/modules/wrapper-manager/default.nix index b3bc6622..171cc576 100644 --- a/modules/wrapper-manager/default.nix +++ b/modules/wrapper-manager/default.nix @@ -2,6 +2,7 @@ imports = [ ./programs/blender.nix ./programs/zellij.nix + ./programs/neovim.nix ./nixgl.nix ./dconf.nix ./sandboxing diff --git a/modules/wrapper-manager/programs/neovim.nix b/modules/wrapper-manager/programs/neovim.nix new file mode 100644 index 00000000..7c379bf1 --- /dev/null +++ b/modules/wrapper-manager/programs/neovim.nix @@ -0,0 +1,112 @@ +# Basically a poor man's version of NixVim or those configuration options from +# either NixOS or home-manager, really. +{ config, lib, pkgs, ... }: + +let + cfg = config.programs.neovim; + + neovimConfigPluginType = { name, lib, ... }: { + freeformType = with lib.types; attrsOf anything; + options = { + plugin = lib.mkOption { + type = lib.types.package; + description = '' + Package containing the Neovim module. + ''; + }; + + pluginConfig = lib.mkOption { + type = lib.types.lines; + description = '' + Plugin configuration in VimL. + ''; + default = ""; + }; + + optional = lib.mkEnableOption "inclusion of this configuration"; + }; + }; + + neovimConfig = pkgs.neovimUtils.makeNeovimConfig { + inherit (cfg) plugins extraPython3Packages extraLuaPackages; + wrapRc = true; + withRuby = cfg.providers.ruby.enable; + withNodeJs = cfg.providers.nodejs.enable; + withPython = cfg.providers.python.enable; + }; + + finalNeovimPackage = pkgs.wrapNeovimUnstable cfg.package neovimConfig; +in +{ + options.programs.neovim = { + enable = lib.mkEnableOption "Neovim, a terminal text editor"; + + package = lib.mkPackageOption pkgs "neovim-unwrapped" { }; + + executableName = lib.mkOption { + type = lib.types.str; + description = '' + The name of the executable name. Pretty useful for creating multiple + Neovim packages. + ''; + default = "nvim"; + example = "nvim-foodogsquared"; + }; + + plugins = lib.mkOption { + type = with lib.types; listOf (submodule neovimConfigPluginType); + description = '' + List of Neovim plugins to be included within the wrapper. + ''; + default = [ ]; + example = lib.literalExpression '' + [ + { plugin = pkgs.vimPlugins.vim-nickel; } + ] + ''; + }; + + extraPython3Packages = lib.mkOption { + type = with lib.types; functionTo (listOf package); + description = '' + A function containing an extra list of Python packages to be included + in the Neovim installation. + ''; + default = _: [ ]; + example = lib.literalExpression '' + p: with p; [ + numpy + ] + ''; + }; + + extraLuaPackages = lib.mkOption { + type = with lib.types; functionTo (listOf package); + description = '' + A function containing an extra list of Lua packages to be included + within the Neovim installation. + ''; + default = _: [ ]; + example = lib.literalExpression '' + p: with p; [ + lz-n + ] + ''; + }; + + providers = { + python.enable = lib.mkEnableOption "Python provider with Neovim"; + nodejs.enable = lib.mkEnableOption "NodeJS provider with Neovim"; + ruby.enable = lib.mkEnableOption "Ruby provider with Neovim"; + }; + }; + + config = lib.mkIf cfg.enable { + basePackages = finalNeovimPackage; + + wrappers.nvim = { + executableName = cfg.executableName; + arg0 = lib.getExe' finalNeovimPackage "nvim"; + }; + }; +}