···
log = logging.getLogger()
sh = logging.StreamHandler()
34
-
formatter = logging.Formatter('%(name)s:%(levelname)s: %(message)s')
34
+
formatter = logging.Formatter("%(name)s:%(levelname)s: %(message)s")
sh.setFormatter(formatter)
# Import plugin update library from maintainers/scripts/pluginupdate.py
ROOT = Path(os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))))
# Ideally, ROOT.(parent^5) points to root of Nixpkgs official tree
41
-
sys.path.insert(0, os.path.join(ROOT.parent.parent.parent.parent.parent, "maintainers", "scripts"))
42
+
0, os.path.join(ROOT.parent.parent.parent.parent.parent, "maintainers", "scripts")
from pluginupdate import run_nix_expr, PluginDesc
46
+
nvim_treesitter = importlib.import_module("treesitter")
with import <localpkgs> {};
lib.attrNames lua51Packages"""
···
"# GENERATED by ./pkgs/applications/editors/vim/plugins/update.py. Do not edit!"
def isNeovimPlugin(plug: pluginupdate.Plugin) -> bool:
Whether it's a neovim-only plugin
We can check if it's available in lua packages
if plug.normalized_name in luaPlugins:
log.debug("%s is a neovim plugin", plug)
···
class VimEditor(pluginupdate.Editor):
nvim_treesitter_updated = False
70
-
def generate_nix(self, plugins: List[Tuple[PluginDesc, pluginupdate.Plugin]], outfile: str):
74
+
self, plugins: List[Tuple[PluginDesc, pluginupdate.Plugin]], outfile: str
sorted_plugins = sorted(plugins, key=lambda v: v[0].name.lower())
72
-
nvim_treesitter_rev = pluginupdate.run_nix_expr("(import <localpkgs> { }).vimPlugins.nvim-treesitter.src.rev")
77
+
nvim_treesitter_rev = pluginupdate.run_nix_expr(
78
+
"(import <localpkgs> { }).vimPlugins.nvim-treesitter.src.rev"
with open(outfile, "w+") as f:
76
-
f.write(textwrap.dedent("""
{ lib, buildVimPlugin, buildNeovimPlugin, fetchFromGitHub, fetchgit }:
for pdesc, plugin in sorted_plugins:
content = self.plugin2nix(pdesc, plugin)
86
-
if plugin.name == "nvim-treesitter" and plugin.commit != nvim_treesitter_rev:
97
+
plugin.name == "nvim-treesitter"
98
+
and plugin.commit != nvim_treesitter_rev
self.nvim_treesitter_updated = True
print(f"updated {outfile}")
def plugin2nix(self, pdesc: PluginDesc, plugin: pluginupdate.Plugin) -> str:
isNeovim = isNeovimPlugin(plugin)
···
106
-
buildFn="buildNeovimPlugin" if isNeovim else "buildVimPlugin", plugin=plugin, src_nix=src_nix, repo=repo)
118
+
buildFn="buildNeovimPlugin" if isNeovim else "buildVimPlugin",
pluginupdate.update_plugins(self, args)
···
if self.nvim_treesitter_updated:
print("updating nvim-treesitter grammars")
nvim_treesitter_dir = ROOT.joinpath("nvim-treesitter")
117
-
subprocess.check_call([nvim_treesitter_dir.joinpath("update.py")])
132
+
# subprocess.check_call([nvim_treesitter_dir.joinpath("update.py")])
133
+
nvim_treesitter.update_grammars()
index = self.nixpkgs_repo.index
for diff in index.diff(None):
122
-
if diff.a_path == "pkgs/applications/editors/vim/plugins/nvim-treesitter/generated.nix":
140
+
== "pkgs/applications/editors/vim/plugins/nvim-treesitter/generated.nix"
msg = "vimPlugins.nvim-treesitter: update grammars"
print(f"committing to nixpkgs: {msg}")
index.add([str(nvim_treesitter_dir.joinpath("generated.nix"))])
···
luaPlugins = run_nix_expr(GET_PLUGINS_LUA)