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

This commit is contained in:
figsoda
2022-12-29 21:31:03 -05:00
parent 67b0f840da
commit b12686d592
3 changed files with 7 additions and 48 deletions
@@ -1,6 +1,6 @@
# generated by pkgs/applications/editors/vim/plugins/nvim-treesitter/update.py
{ buildGrammar, fetchFromGitHub, fetchFromGitLab, fetchgit }:
{ buildGrammar, fetchFromGitHub, fetchFromGitLab, fetchFromSourcehut, fetchgit }:
{
ada = buildGrammar {
@@ -11,7 +11,7 @@ let
in
mkShell {
packages = [ neovim nix-prefetch python3 ];
packages = [ neovim nurl python3 ];
NVIM_TREESITTER = nvim-treesitter;
}
@@ -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"