refactor: date versioning

This commit is contained in:
isabel 2025-03-05 09:55:59 +00:00
parent a7afe929ea
commit 4bb27b0fa2
No known key found for this signature in database
GPG key ID: 3E7C7A1B5DEDBB03
3 changed files with 24 additions and 16 deletions

View file

@ -10,13 +10,20 @@
grammars ? [ ],
}:
let
inherit (builtins)
map
replaceStrings
attrNames
removeAttrs
;
nv = callPackage ./_sources/generated.nix { };
grammarOverrides = callPackage ./grammar-overrides.nix { };
grammarOverrides = import ./grammar-overrides.nix;
# get all grammars from the nvfetcher output
allGrammars = builtins.map (name: lib.removePrefix "treesitter-grammar-" name) (
builtins.attrNames (
builtins.removeAttrs nv [
allGrammars = map (name: lib.removePrefix "treesitter-grammar-" name) (
attrNames (
removeAttrs nv [
"nvim-treesitter"
"override"
"overrideDerivation"
@ -28,27 +35,29 @@ let
if (grammars == [ ]) then allGrammars else lib.intersectLists grammars allGrammars;
# build each Grammar
treesitterGrammars = builtins.map (
treesitterGrammars = map (
name:
let
nvgrammar = nv."treesitter-grammar-${name}";
in
tree-sitter.buildGrammar (
{
inherit (nvgrammar) src version;
inherit (nvgrammar) src;
version = replaceStrings [ "-" ] [ "." ] nvgrammar.date;
language = name;
generate = lib.hasAttr "generate" nvgrammar;
generate = nvgrammar ? "generate";
location = nvgrammar.location or null;
}
// grammarOverrides.${name} or { }
)
) grammarsToBuild;
linkCommands = builtins.map (
linkCommands = map (
grammar:
let
name = lib.removeSuffix "-grammar" grammar.pname;
in
# bash
''
ln -sf ${grammar}/parser ./parser/${name}.so
@ -84,11 +93,15 @@ let
'';
nvim-treesitter = vimUtils.buildVimPlugin {
inherit (nv.nvim-treesitter) pname version src;
inherit (nv.nvim-treesitter) pname src;
version = replaceStrings [ "-" ] [ "." ] nv.nvim-treesitter.date;
postPatch = lib.concatStrings linkCommands;
passthru = {
grammars = treesitterGrammars;
inherit neovim;
tests = {
inherit check-queries;
};

View file

@ -1,4 +1,4 @@
_: {
{
nu = {
postPatch = ''
mv queries/nu/* queries/

View file

@ -1,13 +1,8 @@
{
callPackage,
neovim-unwrapped,
neovimUtils,
wrapNeovimUnstable,
grammars ? [ ],
}:
let
nvim-treesitter = callPackage ./default.nix { inherit grammars; };
in
wrapNeovimUnstable neovim-unwrapped (
neovimUtils.makeNeovimConfig { plugins = [ nvim-treesitter ]; }
)
nvim-treesitter.passthru.neovim