vimPluginsUpdater: fix nvim-treesitter grammars update
This commit is contained in:
parent
86e3c2f58e
commit
be4d94890e
2 changed files with 12 additions and 7 deletions
|
@ -63,14 +63,14 @@ def update_grammars(nvim_treesitter_dir: str):
|
|||
|
||||
generated_file = """# generated by pkgs/applications/editors/vim/plugins/nvim-treesitter/update.py
|
||||
|
||||
{ buildGrammar, """
|
||||
{ buildGrammar, """
|
||||
|
||||
generated_file += subprocess.check_output(["nurl", "-Ls", ", "], text=True)
|
||||
|
||||
generated_file += """ }:
|
||||
|
||||
{
|
||||
"""
|
||||
{
|
||||
"""
|
||||
|
||||
lockfile_path = os.path.join(nvim_treesitter_dir, "lockfile.json")
|
||||
log.debug("Opening %s", lockfile_path)
|
||||
|
@ -88,7 +88,8 @@ def update_grammars(nvim_treesitter_dir: str):
|
|||
_generate_grammar, lockfile.items()
|
||||
):
|
||||
generated_file += generated
|
||||
generated_file += "}\n"
|
||||
|
||||
generated_file += "}\n"
|
||||
return generated_file
|
||||
|
||||
|
||||
|
|
|
@ -138,15 +138,19 @@ class VimEditor(pluginupdate.Editor):
|
|||
nvim_treesitter_dir = subprocess.check_output(cmd, text=True, timeout=90).strip()
|
||||
|
||||
generated = treesitter.update_grammars(nvim_treesitter_dir)
|
||||
open(os.path.join(args.nixpkgs, "generated.nix"), "w").write(generated)
|
||||
treesitter_generated_nix_path = os.path.join(
|
||||
NIXPKGS_NVIMTREESITTER_FOLDER,
|
||||
"generated.nix"
|
||||
)
|
||||
open(os.path.join(args.nixpkgs, treesitter_generated_nix_path), "w").write(generated)
|
||||
|
||||
if self.nixpkgs_repo:
|
||||
index = self.nixpkgs_repo.index
|
||||
for diff in index.diff(None):
|
||||
if diff.a_path == f"{NIXPKGS_NVIMTREESITTER_FOLDER}/generated.nix":
|
||||
if diff.a_path == treesitter_generated_nix_path:
|
||||
msg = "vimPlugins.nvim-treesitter: update grammars"
|
||||
print(f"committing to nixpkgs: {msg}")
|
||||
index.add([str(nvim_treesitter_dir.joinpath("generated.nix"))])
|
||||
index.add([treesitter_generated_nix_path])
|
||||
index.commit(msg)
|
||||
return
|
||||
print("no updates to nvim-treesitter grammars")
|
||||
|
|
Loading…
Reference in a new issue