about summary refs log tree commit diff
path: root/pkgs/applications/editors/vim/plugins/nvim-treesitter/update.py
diff options
context:
space:
mode:
authorfigsoda <figsoda@pm.me>2022-12-29 21:31:03 -0500
committerfigsoda <figsoda@pm.me>2022-12-29 21:31:03 -0500
commitb12686d592cb5b37924fd5ed93ac55ceb1b2c050 (patch)
tree90bab28419249c53666eab3fb5ac6ba8f672f7d0 /pkgs/applications/editors/vim/plugins/nvim-treesitter/update.py
parent67b0f840da78187f0c1f18519d741c7dd16463b3 (diff)
vimPlugins.nvim-treesitter: switch to nurl in update script
Diffstat (limited to 'pkgs/applications/editors/vim/plugins/nvim-treesitter/update.py')
-rwxr-xr-xpkgs/applications/editors/vim/plugins/nvim-treesitter/update.py51
1 files changed, 5 insertions, 46 deletions
diff --git a/pkgs/applications/editors/vim/plugins/nvim-treesitter/update.py b/pkgs/applications/editors/vim/plugins/nvim-treesitter/update.py
index a780633112674..416a6d7f96a86 100755
--- a/pkgs/applications/editors/vim/plugins/nvim-treesitter/update.py
+++ b/pkgs/applications/editors/vim/plugins/nvim-treesitter/update.py
@@ -2,8 +2,8 @@
 #!nix-shell update-shell.nix -i python
 
 import json
-import re
 import subprocess
+from concurrent.futures import ThreadPoolExecutor
 from os import environ
 from os.path import dirname, join
 
@@ -22,8 +22,6 @@ configs = json.loads(
     )
 )
 
-regex = re.compile("^https?://(github.com|gitlab.com)/(.+?)/(.+?)(.git)?$")
-
 
 def generate_grammar(item):
     lang, lock = item
@@ -40,47 +38,8 @@ def generate_grammar(item):
     version = "{rev[:7]}";
     source = """
 
-    m = regex.fullmatch(url)
-    cmd = ["nix-prefetch", "--rev", rev]
-
-    match m and m.group(1, 2, 3):
-        case "github.com", owner, repo:
-            cmd += [
-                "fetchFromGitHub",
-                "--owner",
-                owner,
-                "--repo",
-                repo,
-            ]
-
-            generated += f"""fetchFromGitHub {{
-      owner = "{owner}";
-      repo = "{repo}";"""
-
-        case "gitlab.com", owner, repo:
-            cmd += [
-                "fetchFromGitLab",
-                "--owner",
-                owner,
-                "--repo",
-                repo,
-            ]
-
-            generated += f"""fetchFromGitLab {{
-      owner = "{owner}";
-      repo = "{repo}";"""
-
-        case _:
-            cmd += ["fetchgit", "--url", url]
-            generated += f"""fetchgit {{
-      url = "{url}";"""
-
-    hash = subprocess.check_output(cmd, text=True).strip()
-
-    generated += f"""
-      rev = "{rev}";
-      hash = "{hash}";
-    }};"""
+    generated += subprocess.check_output(["nurl", url, rev, "--indent=4"], text=True)
+    generated += ";"
 
     location = info.get("location")
     if location:
@@ -101,12 +60,12 @@ def generate_grammar(item):
 
 generated_file = """# generated by pkgs/applications/editors/vim/plugins/nvim-treesitter/update.py
 
-{ buildGrammar, fetchFromGitHub, fetchFromGitLab, fetchgit }:
+{ buildGrammar, fetchFromGitHub, fetchFromGitLab, fetchFromSourcehut, fetchgit }:
 
 {
 """
 
-for generated in map(generate_grammar, lockfile.items()):
+for generated in ThreadPoolExecutor().map(generate_grammar, lockfile.items()):
     generated_file += generated
 
 generated_file += "}\n"