mirror of
https://github.com/iofq/nvim-treesitter-main.git
synced 2026-01-23 01:15:17 -06:00
This commit is contained in:
parent
1f19cc0a90
commit
d7acb39fda
4 changed files with 93 additions and 35 deletions
73
overlay.nix
73
overlay.nix
|
|
@ -46,40 +46,63 @@ let
|
|||
# pkgs.vimPlugins.nvim-treesitter.withAllGrammars
|
||||
withPlugins =
|
||||
f:
|
||||
final.vimPlugins.nvim-treesitter.overrideAttrs {
|
||||
passthru.dependencies = map grammarToPlugin (f (tree-sitter.builtGrammars // builtGrammars));
|
||||
};
|
||||
let
|
||||
grammars = (f (tree-sitter.builtGrammars // builtGrammars));
|
||||
grammarNames = lib.concatStringsSep " " (
|
||||
map (g: builtins.elemAt (builtins.split "-" g.name) 0) grammars
|
||||
);
|
||||
bundle = pkgs.symlinkJoin {
|
||||
name = "nvim-treesitter-bundle";
|
||||
paths = map grammarToPlugin grammars;
|
||||
};
|
||||
in
|
||||
final.vimPlugins.nvim-treesitter-unwrapped.overrideAttrs (old: {
|
||||
postInstall = old.postInstall + ''
|
||||
# ensure runtime queries get linked to RTP (:TSInstall does this too)
|
||||
mkdir -p $out/queries
|
||||
for grammar in ${grammarNames}; do
|
||||
ln -sfT $src/runtime/queries/$grammar $out/queries/$grammar
|
||||
done
|
||||
|
||||
# patch nvim-treesitter with parser bundle path
|
||||
ln -sfT ${bundle}/parser $out/parser
|
||||
substituteInPlace $out/lua/nvim-treesitter/config.lua \
|
||||
--replace-fail "install_dir = vim.fs.joinpath(vim.fn.stdpath('data'), 'site')," \
|
||||
"install_dir = '$out'"
|
||||
'';
|
||||
});
|
||||
|
||||
withAllGrammars = withPlugins (_: allGrammars);
|
||||
in
|
||||
{
|
||||
vimPlugins = prev.vimPlugins.extend (
|
||||
final': prev': {
|
||||
nvim-treesitter = prev'.nvim-treesitter.overrideAttrs (old: rec {
|
||||
src = inputs.nvim-treesitter;
|
||||
name = "${old.pname}-${src.rev}";
|
||||
postPatch = "";
|
||||
# ensure runtime queries get linked to RTP (:TSInstall does this too)
|
||||
postInstall = "
|
||||
mkdir -p $out/queries
|
||||
cp -a $src/runtime/queries/* $out/queries
|
||||
";
|
||||
passthru = (prev'.nvim-treesitter.passthru or { }) // {
|
||||
inherit
|
||||
builtGrammars
|
||||
allGrammars
|
||||
grammarToPlugin
|
||||
withPlugins
|
||||
withAllGrammars
|
||||
;
|
||||
final': prev': rec {
|
||||
nvim-treesitter-unwrapped = (
|
||||
prev'.nvim-treesitter.overrideAttrs (old: rec {
|
||||
src = inputs.nvim-treesitter;
|
||||
name = "${old.pname}-${src.rev}";
|
||||
postPatch = "";
|
||||
# ensure runtime queries get linked to RTP (:TSInstall does this too)
|
||||
passthru = (prev'.nvim-treesitter.passthru or { }) // {
|
||||
inherit
|
||||
builtGrammars
|
||||
allGrammars
|
||||
grammarToPlugin
|
||||
withPlugins
|
||||
withAllGrammars
|
||||
;
|
||||
|
||||
grammarPlugins = lib.mapAttrs (_: grammarToPlugin) generatedDerivations;
|
||||
};
|
||||
nvimSkipModules = [ "nvim-treesitter._meta.parsers" ];
|
||||
})
|
||||
);
|
||||
nvim-treesitter = nvim-treesitter-unwrapped;
|
||||
|
||||
grammarPlugins = lib.mapAttrs (_: grammarToPlugin) generatedDerivations;
|
||||
};
|
||||
nvimSkipModules = [ "nvim-treesitter._meta.parsers" ];
|
||||
});
|
||||
nvim-treesitter-textobjects = prev'.nvim-treesitter-textobjects.overrideAttrs (old: {
|
||||
version = inputs.nvim-treesitter-textobjects.rev;
|
||||
src = inputs.nvim-treesitter-textobjects;
|
||||
dependencies = [ final'.nvim-treesitter ];
|
||||
});
|
||||
}
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue