Unverified Commit 46e6cf2e authored by Heitor Augusto's avatar Heitor Augusto Committed by GitHub
Browse files

wrapNeovim: symlink treesitter grammars in the wrapper (#479049)

parents 504414a3 eadca93f
Loading
Loading
Loading
Loading
+7 −5
Original line number Diff line number Diff line
@@ -60,7 +60,7 @@ let
    };

  /**
    * Builds a vim package (see ':h packages') with additionnal info:
    * Builds a vim package (see ':h packages') with additional info:
    - the user lua configuration (specified by user)
    - the advised and advised by nixpkgs in passthru.initLua)
    - runtime dependencies (specified in plugins' "runtimeDeps")
@@ -110,7 +110,7 @@ let
      # viml config set by the user along with the plugin
      inherit userPluginViml;

      # recommanded configuration set in vim plugins ".passthru.initLua"
      # recommended configuration set in vim plugins ".passthru.initLua"
      inherit pluginAdvisedLua;

      # A Vim "package", see ':h packages'
@@ -135,8 +135,8 @@ let
    arguments (["-u" writeText "init.vim" GENERATEDRC)]).
    This makes it possible to write the config anywhere: on a per-project basis
    .nvimrc or in $XDG_CONFIG_HOME/nvim/init.vim to avoid sideeffects.
    Indeed, note that wrapping with `-u init.vim` has sideeffects like .nvimrc wont be loaded
    anymore, $MYVIMRC wont be set etc
    Indeed, note that wrapping with `-u init.vim` has sideeffects like .nvimrc won't be loaded
    anymore, $MYVIMRC won't be set etc
  */
  makeNeovimConfig =
    {
@@ -344,7 +344,9 @@ let

          nativeBuildInputs = [ toNvimTreesitterGrammar ];

          passthru = grammar.passthru or { };
          passthru = grammar.passthru or { } // {
            isTreesitterGrammar = true;
          };

          meta = {
            platforms = lib.platforms.all;
+1 −2
Original line number Diff line number Diff line
@@ -338,8 +338,7 @@ let
          unwrapped = neovim-unwrapped;
          initRc = neovimRcContent';

          tests = callPackage ./tests {
          };
          tests = callPackage ./tests { };
        };

        meta = {
+5 −7
Original line number Diff line number Diff line
@@ -21,7 +21,10 @@ let
    vimUtils.toVimPlugin (
      runCommand "nvim-treesitter-queries-${language}"
        {
          passthru = { inherit language; };
          passthru = {
            inherit language;
            isTreesitterQuery = true;
          };
          meta.description = "Queries for ${language} from nvim-treesitter";
        }
        ''
@@ -94,12 +97,7 @@ let
      ];
    in
    self.nvim-treesitter.overrideAttrs {
      passthru.dependencies = [
        (symlinkJoin {
          name = "nvim-treesitter-grammars";
          paths = grammarPlugins ++ queryPlugins;
        })
      ];
      passthru.dependencies = grammarPlugins ++ queryPlugins;
    };

  withAllGrammars = withPlugins (_: allGrammars);
+17 −2
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@
  vim,
  vimPlugins,
  buildEnv,
  symlinkJoin,
  writeText,
  runCommand,
  makeWrapper,
@@ -200,12 +201,26 @@ let
          # and can simply pass `null`.
          depsOfOptionalPlugins = lib.subtractLists opt (findDependenciesRecursively opt);
          startWithDeps = findDependenciesRecursively start;
          allPlugins = lib.unique (startWithDeps ++ depsOfOptionalPlugins);
          allPluginsAndGrammars = lib.unique (startWithDeps ++ depsOfOptionalPlugins);

          allPython3Dependencies =
            ps: lib.flatten (map (plugin: (plugin.python3Dependencies or (_: [ ])) ps) allPlugins);
          python3Env = python3.withPackages allPython3Dependencies;

          packdirStart = vimFarm "pack/${packageName}/start" "packdir-start" allPlugins;
          partitionGrammars = lib.partition (
            p: p.isTreesitterGrammar or false || p.isTreesitterQuery or false
          );
          allPluginsAndGrammarsPartitioned = partitionGrammars allPluginsAndGrammars;
          allPlugins = allPluginsAndGrammarsPartitioned.wrong;
          allGrammars = allPluginsAndGrammarsPartitioned.right;
          allGrammarsSymlinked = symlinkJoin {
            name = "nvim-treesitter-grammars";
            paths = allGrammars;
          };

          packdirStart = vimFarm "pack/${packageName}/start" "packdir-start" (
            if allGrammars != [ ] then allPlugins ++ [ allGrammarsSymlinked ] else allPlugins
          );
          packdirOpt = vimFarm "pack/${packageName}/opt" "packdir-opt" opt;
          # Assemble all python3 dependencies into a single `site-packages` to avoid doing recursive dependency collection
          # for each plugin.