mirror of
https://github.com/iofq/nvim-treesitter-main.git
synced 2026-01-23 09:25:17 -06:00
Compare commits
3 commits
cfc655da9d
...
c8b4d718be
| Author | SHA1 | Date | |
|---|---|---|---|
| c8b4d718be | |||
|
|
da2262419e | ||
| eb926e4efe |
4 changed files with 506 additions and 108 deletions
12
flake.lock
generated
12
flake.lock
generated
|
|
@ -2,11 +2,11 @@
|
||||||
"nodes": {
|
"nodes": {
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1759381078,
|
"lastModified": 1760038930,
|
||||||
"narHash": "sha256-gTrEEp5gEspIcCOx9PD8kMaF1iEmfBcTbO0Jag2QhQs=",
|
"narHash": "sha256-Oncbh0UmHjSlxO7ErQDM3KM0A5/Znfofj2BSzlHLeVw=",
|
||||||
"owner": "nixos",
|
"owner": "nixos",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "7df7ff7d8e00218376575f0acdcc5d66741351ee",
|
"rev": "0b4defa2584313f3b781240b29d61f6f9f7e0df3",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
@ -19,11 +19,11 @@
|
||||||
"nvim-treesitter": {
|
"nvim-treesitter": {
|
||||||
"flake": false,
|
"flake": false,
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1759376029,
|
"lastModified": 1760260935,
|
||||||
"narHash": "sha256-Cu6Wg9SKJpYAkp8DPAXe4Rf9OSSWW2wNdmCkYtl//fw=",
|
"narHash": "sha256-To/syCZPs7vKA0WkuBz7ZxCGT/wzj705QfxZng6Nsjo=",
|
||||||
"owner": "nvim-treesitter",
|
"owner": "nvim-treesitter",
|
||||||
"repo": "nvim-treesitter",
|
"repo": "nvim-treesitter",
|
||||||
"rev": "99bd52ba56a4b7c9a8cc50a6140180755e76fac6",
|
"rev": "0606c7a9dcaa5c5beee0b0f09043e9fdd1ba0a68",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,15 @@
|
||||||
|
local function table_to_nix(t)
|
||||||
|
local entries = {}
|
||||||
|
for _, s in ipairs(t) do
|
||||||
|
table.insert(entries, string.format('"%s"', s))
|
||||||
|
end
|
||||||
|
return string.format("[ %s ]", table.concat(entries, " "))
|
||||||
|
end
|
||||||
|
|
||||||
local function fmt_grammar(grammar)
|
local function fmt_grammar(grammar)
|
||||||
local lines = {
|
local lines = {
|
||||||
string.format('%s = buildGrammar {', grammar.language),
|
string.format('%s = buildGrammar {', grammar.language),
|
||||||
|
string.format('passthru.name = "%s";', grammar.language),
|
||||||
string.format('language = "%s";', grammar.language),
|
string.format('language = "%s";', grammar.language),
|
||||||
string.format('version = "%s";', grammar.version),
|
string.format('version = "%s";', grammar.version),
|
||||||
string.format('src = %s;', grammar.src),
|
string.format('src = %s;', grammar.src),
|
||||||
|
|
@ -8,6 +17,10 @@ local function fmt_grammar(grammar)
|
||||||
}
|
}
|
||||||
if grammar.generate then table.insert(lines, string.format('generate = %s;', grammar.generate)) end
|
if grammar.generate then table.insert(lines, string.format('generate = %s;', grammar.generate)) end
|
||||||
if grammar.location then table.insert(lines, string.format('location = "%s";', grammar.location)) end
|
if grammar.location then table.insert(lines, string.format('location = "%s";', grammar.location)) end
|
||||||
|
if grammar.requires then table.insert(
|
||||||
|
lines,
|
||||||
|
string.format('requires = %s;', table_to_nix(grammar.requires))
|
||||||
|
) end
|
||||||
|
|
||||||
table.insert(lines, "};")
|
table.insert(lines, "};")
|
||||||
return table.concat(lines, "\n")
|
return table.concat(lines, "\n")
|
||||||
|
|
@ -42,7 +55,9 @@ local function generate_grammars(g)
|
||||||
if p.install_info.location then
|
if p.install_info.location then
|
||||||
grammar.location = p.install_info.location
|
grammar.location = p.install_info.location
|
||||||
end
|
end
|
||||||
|
if p.requires then
|
||||||
|
grammar.requires = p.requires
|
||||||
|
end
|
||||||
table.insert(output, fmt_grammar(grammar))
|
table.insert(output, fmt_grammar(grammar))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
563
generated.nix
563
generated.nix
File diff suppressed because it is too large
Load diff
20
overlay.nix
20
overlay.nix
|
|
@ -48,19 +48,31 @@ let
|
||||||
f:
|
f:
|
||||||
let
|
let
|
||||||
grammars = (f (tree-sitter.builtGrammars // builtGrammars));
|
grammars = (f (tree-sitter.builtGrammars // builtGrammars));
|
||||||
grammarNames = lib.concatStringsSep " " (
|
|
||||||
map (g: builtins.elemAt (builtins.split "-" g.name) 0) grammars
|
# Grammars that are required by a provided grammar
|
||||||
|
required = lib.unique (lib.concatLists (map (g: g.requires or [ ]) grammars));
|
||||||
|
|
||||||
|
# Append grammars from required that exist in builtGrammars (they actually have a parser)
|
||||||
|
# Need to split these out as some "requires" elements from parsers.lua are just queries
|
||||||
|
# from nvim-treesitter/runtime/queries
|
||||||
|
finalGrammars =
|
||||||
|
grammars
|
||||||
|
++ map (name: builtGrammars.${name}) (
|
||||||
|
builtins.filter (name: builtins.hasAttr name builtGrammars) required
|
||||||
);
|
);
|
||||||
|
|
||||||
|
runtimeQueries = lib.concatStringsSep " " ((map (g: g.passthru.name) grammars) ++ required);
|
||||||
|
|
||||||
bundle = pkgs.symlinkJoin {
|
bundle = pkgs.symlinkJoin {
|
||||||
name = "nvim-treesitter-bundle";
|
name = "nvim-treesitter-bundle";
|
||||||
paths = map grammarToPlugin grammars;
|
paths = map grammarToPlugin finalGrammars;
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
final.vimPlugins.nvim-treesitter-unwrapped.overrideAttrs (old: {
|
final.vimPlugins.nvim-treesitter-unwrapped.overrideAttrs (old: {
|
||||||
postInstall = old.postInstall + ''
|
postInstall = old.postInstall + ''
|
||||||
# ensure runtime queries get linked to RTP (:TSInstall does this too)
|
# ensure runtime queries get linked to RTP (:TSInstall does this too)
|
||||||
mkdir -p $out/queries
|
mkdir -p $out/queries
|
||||||
for grammar in ${grammarNames}; do
|
for grammar in ${runtimeQueries}; do
|
||||||
ln -sfT $src/runtime/queries/$grammar $out/queries/$grammar
|
ln -sfT $src/runtime/queries/$grammar $out/queries/$grammar
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue