summary refs log tree commit diff
diff options
context:
space:
mode:
authorlinsui <36977733+linsui@users.noreply.github.com>2023-04-18 21:20:54 +0000
committerGitHub <noreply@github.com>2023-04-18 23:20:54 +0200
commit7b6d5d41582ccb225bc0468573cae77f7f75b215 (patch)
treec98ab464bfe7c27869eef6acbc92b95edc428337
parent6d9b8796028dde4e3b0c8bebac1666295b914e81 (diff)
downloadnixpkgs-7b6d5d41582ccb225bc0468573cae77f7f75b215.tar
nixpkgs-7b6d5d41582ccb225bc0468573cae77f7f75b215.tar.gz
nixpkgs-7b6d5d41582ccb225bc0468573cae77f7f75b215.tar.bz2
nixpkgs-7b6d5d41582ccb225bc0468573cae77f7f75b215.tar.lz
nixpkgs-7b6d5d41582ccb225bc0468573cae77f7f75b215.tar.xz
nixpkgs-7b6d5d41582ccb225bc0468573cae77f7f75b215.tar.zst
nixpkgs-7b6d5d41582ccb225bc0468573cae77f7f75b215.zip
nixos/neovim: add runtime file to etc/xdg/nvim (#221832)
Else the files in the runtime can't be accessed from the vimrc. I also remove the /etc. I thought it's a leftover of the old runtime implementation which is replaced in 307b125.

Co-authored-by: linsui <linsui555@gmail.com>
-rw-r--r--nixos/modules/programs/neovim.nix47
1 files changed, 21 insertions, 26 deletions
diff --git a/nixos/modules/programs/neovim.nix b/nixos/modules/programs/neovim.nix
index 4562e5a2c29..3f0e9fc173b 100644
--- a/nixos/modules/programs/neovim.nix
+++ b/nixos/modules/programs/neovim.nix
@@ -4,12 +4,8 @@ with lib;
 
 let
   cfg = config.programs.neovim;
-
-  runtime' = filter (f: f.enable) (attrValues cfg.runtime);
-
-  runtime = pkgs.linkFarm "neovim-runtime" (map (x: { name = "etc/${x.target}"; path = x.source; }) runtime');
-
-in {
+in
+{
   options.programs.neovim = {
     enable = mkOption {
       type = types.bool;
@@ -70,7 +66,7 @@ in {
 
     configure = mkOption {
       type = types.attrs;
-      default = {};
+      default = { };
       example = literalExpression ''
         {
           customRC = '''
@@ -105,7 +101,7 @@ in {
     };
 
     runtime = mkOption {
-      default = {};
+      default = { };
       example = literalExpression ''
         { "ftplugin/c.vim".text = "setlocal omnifunc=v:lua.vim.lsp.omnifunc"; }
       '';
@@ -115,14 +111,15 @@ in {
 
       type = with types; attrsOf (submodule (
         { name, config, ... }:
-        { options = {
+        {
+          options = {
 
             enable = mkOption {
               type = types.bool;
               default = true;
               description = lib.mdDoc ''
-                Whether this /etc file should be generated.  This
-                option allows specific /etc files to be disabled.
+                Whether this runtime directory should be generated.  This
+                option allows specific runtime files to be disabled.
               '';
             };
 
@@ -147,14 +144,9 @@ in {
 
           };
 
-          config = {
-            target = mkDefault name;
-            source = mkIf (config.text != null) (
-              let name' = "neovim-runtime" + baseNameOf name;
-              in mkDefault (pkgs.writeText name' config.text));
-          };
-
-        }));
+          config.target = mkDefault name;
+        }
+      ));
 
     };
   };
@@ -165,14 +157,17 @@ in {
     ];
     environment.variables.EDITOR = mkIf cfg.defaultEditor (mkOverride 900 "nvim");
 
-    programs.neovim.finalPackage = pkgs.wrapNeovim cfg.package {
-      inherit (cfg) viAlias vimAlias withPython3 withNodeJs withRuby;
-      configure = cfg.configure // {
+    environment.etc = listToAttrs (attrValues (mapAttrs
+      (name: value: {
+        name = "xdg/nvim/${name}";
+        value = value // {
+          target = "xdg/nvim/${value.target}";
+        };
+      })
+      cfg.runtime));
 
-        customRC = (cfg.configure.customRC or "") + ''
-          set runtimepath^=${runtime}/etc
-        '';
-      };
+    programs.neovim.finalPackage = pkgs.wrapNeovim cfg.package {
+      inherit (cfg) viAlias vimAlias withPython3 withNodeJs withRuby configure;
     };
   };
 }