diff options
| author | Tim Keller <tjk@tjkeller.xyz> | 2026-05-21 22:48:23 -0500 |
|---|---|---|
| committer | Tim Keller <tjk@tjkeller.xyz> | 2026-05-21 22:48:23 -0500 |
| commit | 6055a9d94861e865ed293c7babd033e30777b002 (patch) | |
| tree | e580e17aab102e93b487e332c44220645f22bc3a /home-manager | |
| parent | 4e4ec16117af9dbf1043e8b9e82e908e0efbfa75 (diff) | |
| download | nixos-6055a9d94861e865ed293c7babd033e30777b002.tar.xz nixos-6055a9d94861e865ed293c7babd033e30777b002.zip | |
neovim native plugins and entire hm config section for nvimHEADstandalone-homemaster
Diffstat (limited to 'home-manager')
| -rw-r--r-- | home-manager/default.nix | 1 | ||||
| -rw-r--r-- | home-manager/neovim.nix | 82 |
2 files changed, 83 insertions, 0 deletions
diff --git a/home-manager/default.nix b/home-manager/default.nix index 226552a..8d9c722 100644 --- a/home-manager/default.nix +++ b/home-manager/default.nix @@ -6,6 +6,7 @@ ./home-cleanup.nix ./htop.nix ./mint-theme.nix + ./neovim.nix ./pcmanfm.nix ./qt-gtk-theme.nix ./theme-st.nix diff --git a/home-manager/neovim.nix b/home-manager/neovim.nix new file mode 100644 index 0000000..60608f6 --- /dev/null +++ b/home-manager/neovim.nix @@ -0,0 +1,82 @@ +{ lib, config, pkgs, ... }: let + cfg = config.programs._neovim; + + extraPlugins = cfg.plugins.packages // { + start = (cfg.plugins.packages.start or []) + ++ lib.optionals cfg.plugins.lsp.enable [ cfg.plugins.lsp.pluginPackage ] + ++ lib.optionals cfg.plugins.treesitter.enable [ cfg.plugins.treesitter.pluginPackage ] + ++ lib.optionals cfg.plugins.treesitter.enable cfg.plugins.treesitter.parsers.packages; + }; + pluginDir = pkgs.linkFarm "nvim-site" + (lib.concatLists (lib.mapAttrsToList (stage: plugins: + map (plugin: { + name = "share/nvim/site/pack/plugins/${stage}/${plugin.name}"; + path = plugin; + }) plugins + ) extraPlugins)); + + extraPackages = cfg.extraPackages + ++ lib.optionals cfg.plugins.lsp.enable cfg.plugins.lsp.languageServers.packages; + + finalPackage = pkgs.symlinkJoin { + name = "neovim-not-wrapped"; + paths = [ cfg.package ]; + nativeBuildInputs = [ pkgs.makeWrapper ]; + postBuild = '' + wrapProgram $out/bin/nvim \ + --prefix PATH : ${pkgs.lib.makeBinPath extraPackages} \ + --prefix XDG_DATA_DIRS : ${pluginDir}/share + '' + lib.optionalString cfg.viAlias '' + ln -s $out/bin/nvim $out/bin/vi + '' + lib.optionalString cfg.vimAlias '' + ln -s $out/bin/nvim $out/bin/vim + ''; + }; +in { + options.programs._neovim = { + enable = lib.mkEnableOption "install and configure neovim"; + package = lib.mkPackageOption pkgs "neovim" {}; + viAlias = lib.mkEnableOption "alias vi => nvim"; + vimAlias = lib.mkEnableOption "alias vim => nvim"; + plugins = { + lsp = { + enable = lib.mkEnableOption "install defined language servers into nvim path"; + pluginPackage = lib.mkPackageOption pkgs.vimPlugins "nvim-lspconfig" {}; + languageServers.packages = lib.mkOption { + type = lib.types.listOf lib.types.package; + default = [ ]; + description = "language server packages to add to nvim path when lsp is enabled"; + }; + }; + treesitter = { + enable = lib.mkEnableOption "install treesitter and parsers as nvim plugins"; + pluginPackage = lib.mkPackageOption pkgs.vimPlugins "nvim-treesitter" {}; + parsers.packages = lib.mkOption { + type = lib.types.listOf lib.types.package; + default = [ ]; + description = "treesitter parsers to install as plugins"; + }; + }; + packages = lib.mkOption { + type = lib.types.attrsOf (lib.types.listOf lib.types.package); + default = [ ]; + example = { + start = with pkgs.vimPlugins; [ + nvim-colorizer-lua + ]; + }; + description = "extra plugins to be made available to nvim via packpath, organized by stage"; + }; + }; + extraPackages = lib.mkOption { + type = lib.types.listOf lib.types.package; + default = [ ]; + description = "extra packages to add to nvim path"; + }; + }; + + config = lib.mkIf cfg.enable { + # NOTE: Don't use programs.neovim since that will build neovim from source + home.packages = [ finalPackage ]; + }; +} |
