From be4d94890e639be870e525c2158308b9bd39278b Mon Sep 17 00:00:00 2001 From: Gaetan Lepage Date: Mon, 16 Oct 2023 13:32:33 +0200 Subject: [PATCH] vimPluginsUpdater: fix nvim-treesitter grammars update --- .../editors/vim/plugins/nvim-treesitter/update.py | 9 +++++---- pkgs/applications/editors/vim/plugins/update.py | 10 +++++++--- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/pkgs/applications/editors/vim/plugins/nvim-treesitter/update.py b/pkgs/applications/editors/vim/plugins/nvim-treesitter/update.py index 6d9fd4de0984e..4b70d8555dd2e 100755 --- a/pkgs/applications/editors/vim/plugins/nvim-treesitter/update.py +++ b/pkgs/applications/editors/vim/plugins/nvim-treesitter/update.py @@ -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 _generate_grammar(item): _generate_grammar, lockfile.items() ): generated_file += generated - generated_file += "}\n" + + generated_file += "}\n" return generated_file diff --git a/pkgs/applications/editors/vim/plugins/update.py b/pkgs/applications/editors/vim/plugins/update.py index b658ca7e2bd92..e7e50c21d475e 100755 --- a/pkgs/applications/editors/vim/plugins/update.py +++ b/pkgs/applications/editors/vim/plugins/update.py @@ -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")