tree-sitter: Add withPlugins

authored by

José Luis Lafuente and committed by
Matthieu Coudron
f29292db a48ea1b0

+51 -1
+30 -1
pkgs/development/tools/parsing/tree-sitter/default.nix
··· 71 71 in 72 72 lib.mapAttrs change grammars; 73 73 74 + # Usage: 75 + # pkgs.tree-sitter.withPlugins (p: [ p.tree-sitter-c p.tree-sitter-java ... ]) 76 + # 77 + # or for all grammars: 78 + # pkgs.tree-sitter.withPlugins (_: allGrammars) 79 + # which is equivalent to 80 + # pkgs.tree-sitter.withPlugins (p: builtins.attrValues p) 81 + withPlugins = grammarFn: 82 + let 83 + grammars = grammarFn builtGrammars; 84 + in 85 + linkFarm "grammars" 86 + (map 87 + (drv: 88 + let 89 + name = lib.strings.getName drv; 90 + in 91 + { 92 + name = 93 + (lib.strings.removePrefix "tree-sitter-" 94 + (lib.strings.removeSuffix "-grammar" name)) 95 + + stdenv.hostPlatform.extensions.sharedLibrary; 96 + path = "${drv}/parser"; 97 + } 98 + ) 99 + grammars); 100 + 101 + allGrammars = builtins.attrValues builtGrammars; 102 + 74 103 in 75 104 rustPlatform.buildRustPackage { 76 105 pname = "tree-sitter"; ··· 111 140 updater = { 112 141 inherit update-all-grammars; 113 142 }; 114 - inherit grammars builtGrammars; 143 + inherit grammars builtGrammars withPlugins allGrammars; 115 144 116 145 tests = { 117 146 # make sure all grammars build
+21
pkgs/misc/vim-plugins/overrides.nix
··· 50 50 , CoreFoundation 51 51 , CoreServices 52 52 53 + # nvim-treesitter dependencies 54 + , tree-sitter 55 + 53 56 # sved dependencies 54 57 , glib 55 58 , gobject-introspection ··· 362 365 363 366 nvim-lsputils = super.nvim-lsputils.overrideAttrs (old: { 364 367 dependencies = with super; [ popfix ]; 368 + }); 369 + 370 + # Usage: 371 + # pkgs.vimPlugins.nvim-treesitter.withPlugins (p: [ p.tree-sitter-c p.tree-sitter-java ... ]) 372 + # or for all grammars: 373 + # pkgs.vimPlugins.nvim-treesitter.withPlugins (_: tree-sitter.allGrammars) 374 + nvim-treesitter = super.nvim-treesitter.overrideAttrs (old: { 375 + passthru.withPlugins = 376 + grammarFn: self.nvim-treesitter.overrideAttrs (_: { 377 + postPatch = 378 + let 379 + grammars = tree-sitter.withPlugins grammarFn; 380 + in 381 + '' 382 + rm -r parser 383 + ln -s ${grammars} parser 384 + ''; 385 + }); 365 386 }); 366 387 367 388 onehalf = super.onehalf.overrideAttrs (old: {