vimPlugins.nvim-treesitter: switch to nurl in update script

figsoda b12686d5 67b0f840

+7 -48
+1 -1
pkgs/applications/editors/vim/plugins/nvim-treesitter/generated.nix
··· 1 1 # generated by pkgs/applications/editors/vim/plugins/nvim-treesitter/update.py 2 2 3 - { buildGrammar, fetchFromGitHub, fetchFromGitLab, fetchgit }: 3 + { buildGrammar, fetchFromGitHub, fetchFromGitLab, fetchFromSourcehut, fetchgit }: 4 4 5 5 { 6 6 ada = buildGrammar {
+1 -1
pkgs/applications/editors/vim/plugins/nvim-treesitter/update-shell.nix
··· 11 11 in 12 12 13 13 mkShell { 14 - packages = [ neovim nix-prefetch python3 ]; 14 + packages = [ neovim nurl python3 ]; 15 15 16 16 NVIM_TREESITTER = nvim-treesitter; 17 17 }
+5 -46
pkgs/applications/editors/vim/plugins/nvim-treesitter/update.py
··· 2 2 #!nix-shell update-shell.nix -i python 3 3 4 4 import json 5 - import re 6 5 import subprocess 6 + from concurrent.futures import ThreadPoolExecutor 7 7 from os import environ 8 8 from os.path import dirname, join 9 9 ··· 21 21 ] 22 22 ) 23 23 ) 24 - 25 - regex = re.compile("^https?://(github.com|gitlab.com)/(.+?)/(.+?)(.git)?$") 26 24 27 25 28 26 def generate_grammar(item): ··· 40 38 version = "{rev[:7]}"; 41 39 source = """ 42 40 43 - m = regex.fullmatch(url) 44 - cmd = ["nix-prefetch", "--rev", rev] 45 - 46 - match m and m.group(1, 2, 3): 47 - case "github.com", owner, repo: 48 - cmd += [ 49 - "fetchFromGitHub", 50 - "--owner", 51 - owner, 52 - "--repo", 53 - repo, 54 - ] 55 - 56 - generated += f"""fetchFromGitHub {{ 57 - owner = "{owner}"; 58 - repo = "{repo}";""" 59 - 60 - case "gitlab.com", owner, repo: 61 - cmd += [ 62 - "fetchFromGitLab", 63 - "--owner", 64 - owner, 65 - "--repo", 66 - repo, 67 - ] 68 - 69 - generated += f"""fetchFromGitLab {{ 70 - owner = "{owner}"; 71 - repo = "{repo}";""" 72 - 73 - case _: 74 - cmd += ["fetchgit", "--url", url] 75 - generated += f"""fetchgit {{ 76 - url = "{url}";""" 77 - 78 - hash = subprocess.check_output(cmd, text=True).strip() 79 - 80 - generated += f""" 81 - rev = "{rev}"; 82 - hash = "{hash}"; 83 - }};""" 41 + generated += subprocess.check_output(["nurl", url, rev, "--indent=4"], text=True) 42 + generated += ";" 84 43 85 44 location = info.get("location") 86 45 if location: ··· 101 60 102 61 generated_file = """# generated by pkgs/applications/editors/vim/plugins/nvim-treesitter/update.py 103 62 104 - { buildGrammar, fetchFromGitHub, fetchFromGitLab, fetchgit }: 63 + { buildGrammar, fetchFromGitHub, fetchFromGitLab, fetchFromSourcehut, fetchgit }: 105 64 106 65 { 107 66 """ 108 67 109 - for generated in map(generate_grammar, lockfile.items()): 68 + for generated in ThreadPoolExecutor().map(generate_grammar, lockfile.items()): 110 69 generated_file += generated 111 70 112 71 generated_file += "}\n"