tree-sitter: Add withPlugins
This commit is contained in:
parent
a48ea1b0b3
commit
f29292db76
|
@ -71,6 +71,35 @@ let
|
|||
in
|
||||
lib.mapAttrs change grammars;
|
||||
|
||||
# Usage:
|
||||
# pkgs.tree-sitter.withPlugins (p: [ p.tree-sitter-c p.tree-sitter-java ... ])
|
||||
#
|
||||
# or for all grammars:
|
||||
# pkgs.tree-sitter.withPlugins (_: allGrammars)
|
||||
# which is equivalent to
|
||||
# pkgs.tree-sitter.withPlugins (p: builtins.attrValues p)
|
||||
withPlugins = grammarFn:
|
||||
let
|
||||
grammars = grammarFn builtGrammars;
|
||||
in
|
||||
linkFarm "grammars"
|
||||
(map
|
||||
(drv:
|
||||
let
|
||||
name = lib.strings.getName drv;
|
||||
in
|
||||
{
|
||||
name =
|
||||
(lib.strings.removePrefix "tree-sitter-"
|
||||
(lib.strings.removeSuffix "-grammar" name))
|
||||
+ stdenv.hostPlatform.extensions.sharedLibrary;
|
||||
path = "${drv}/parser";
|
||||
}
|
||||
)
|
||||
grammars);
|
||||
|
||||
allGrammars = builtins.attrValues builtGrammars;
|
||||
|
||||
in
|
||||
rustPlatform.buildRustPackage {
|
||||
pname = "tree-sitter";
|
||||
|
@ -111,7 +140,7 @@ rustPlatform.buildRustPackage {
|
|||
updater = {
|
||||
inherit update-all-grammars;
|
||||
};
|
||||
inherit grammars builtGrammars;
|
||||
inherit grammars builtGrammars withPlugins allGrammars;
|
||||
|
||||
tests = {
|
||||
# make sure all grammars build
|
||||
|
|
|
@ -50,6 +50,9 @@
|
|||
, CoreFoundation
|
||||
, CoreServices
|
||||
|
||||
# nvim-treesitter dependencies
|
||||
, tree-sitter
|
||||
|
||||
# sved dependencies
|
||||
, glib
|
||||
, gobject-introspection
|
||||
|
@ -364,6 +367,24 @@ self: super: {
|
|||
dependencies = with super; [ popfix ];
|
||||
});
|
||||
|
||||
# Usage:
|
||||
# pkgs.vimPlugins.nvim-treesitter.withPlugins (p: [ p.tree-sitter-c p.tree-sitter-java ... ])
|
||||
# or for all grammars:
|
||||
# pkgs.vimPlugins.nvim-treesitter.withPlugins (_: tree-sitter.allGrammars)
|
||||
nvim-treesitter = super.nvim-treesitter.overrideAttrs (old: {
|
||||
passthru.withPlugins =
|
||||
grammarFn: self.nvim-treesitter.overrideAttrs (_: {
|
||||
postPatch =
|
||||
let
|
||||
grammars = tree-sitter.withPlugins grammarFn;
|
||||
in
|
||||
''
|
||||
rm -r parser
|
||||
ln -s ${grammars} parser
|
||||
'';
|
||||
});
|
||||
});
|
||||
|
||||
onehalf = super.onehalf.overrideAttrs (old: {
|
||||
configurePhase = "cd vim";
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue