tree-sitter: Add withPlugins
This commit is contained in:
parent
a48ea1b0b3
commit
f29292db76
@ -71,6 +71,35 @@ let
|
|||||||
in
|
in
|
||||||
lib.mapAttrs change grammars;
|
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
|
in
|
||||||
rustPlatform.buildRustPackage {
|
rustPlatform.buildRustPackage {
|
||||||
pname = "tree-sitter";
|
pname = "tree-sitter";
|
||||||
@ -111,7 +140,7 @@ rustPlatform.buildRustPackage {
|
|||||||
updater = {
|
updater = {
|
||||||
inherit update-all-grammars;
|
inherit update-all-grammars;
|
||||||
};
|
};
|
||||||
inherit grammars builtGrammars;
|
inherit grammars builtGrammars withPlugins allGrammars;
|
||||||
|
|
||||||
tests = {
|
tests = {
|
||||||
# make sure all grammars build
|
# make sure all grammars build
|
||||||
|
@ -50,6 +50,9 @@
|
|||||||
, CoreFoundation
|
, CoreFoundation
|
||||||
, CoreServices
|
, CoreServices
|
||||||
|
|
||||||
|
# nvim-treesitter dependencies
|
||||||
|
, tree-sitter
|
||||||
|
|
||||||
# sved dependencies
|
# sved dependencies
|
||||||
, glib
|
, glib
|
||||||
, gobject-introspection
|
, gobject-introspection
|
||||||
@ -364,6 +367,24 @@ self: super: {
|
|||||||
dependencies = with super; [ popfix ];
|
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: {
|
onehalf = super.onehalf.overrideAttrs (old: {
|
||||||
configurePhase = "cd vim";
|
configurePhase = "cd vim";
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user