Skip to content

Commit

Permalink
vimPluginsUpdater: fix nvim-treesitter grammars update
Browse files Browse the repository at this point in the history
  • Loading branch information
GaetanLepage authored and teto committed Oct 16, 2023
1 parent 86e3c2f commit be4d948
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -88,7 +88,8 @@ def _generate_grammar(item):
_generate_grammar, lockfile.items()
):
generated_file += generated
generated_file += "}\n"

generated_file += "}\n"
return generated_file


Expand Down
10 changes: 7 additions & 3 deletions pkgs/applications/editors/vim/plugins/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,19 @@ def update(self, args):
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")
Expand Down

0 comments on commit be4d948

Please sign in to comment.