From 34329ca2ff3b3263172114c8f34b5b824170cd9d Mon Sep 17 00:00:00 2001 From: Thomas Schmucker Date: Mon, 3 Aug 2026 08:02:01 +0200 Subject: neovim: Neue Funktion 'update_parsers' und entsprechendes UserCmd --- nvim/lua/config/usercmds.lua | 16 ++++++++++++++++ windows/bin/nvim-update.cmd | 2 +- zsh/zshrc | 2 +- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/nvim/lua/config/usercmds.lua b/nvim/lua/config/usercmds.lua index 529b370..c9fc81d 100644 --- a/nvim/lua/config/usercmds.lua +++ b/nvim/lua/config/usercmds.lua @@ -66,6 +66,21 @@ local function enable_lsp() vim.cmd("edit") -- triggert Reattach bei vielen Setups end +local function update_parsers() + local install = require("nvim-treesitter.install") + local langs = require("config.treesitter").languages + + -- install() installiert fehlende Parser, ueberspringt aber bereits + -- installierte unabhaengig von deren Revision. update() aktualisiert + -- nur bereits installierte Parser, ignoriert aber fehlende. Beides ist + -- ausserdem async (gibt einen Task zurueck statt zu blockieren) - + -- deshalb :wait(), damit z.B. headless-Aufrufe (nvim-update) nicht + -- vorzeitig per "qa" abgebrochen werden, bevor Download/Kompilierung + -- fertig sind. + install.install(langs, { summary = true }):wait() + install.update(langs, { summary = true }):wait() +end + -- sonar-scanner/scripts/sonarqube.sh sind POSIX-only (kein Windows-Pendant), -- deshalb Kommandos unter Windows gar nicht erst registrieren statt sie -- dort fehlschlagen zu lassen. @@ -79,3 +94,4 @@ end vim.api.nvim_create_user_command("LspOff", disable_lsp, {}) vim.api.nvim_create_user_command("LspOffBuffer", disable_lsp_buffer, {}) vim.api.nvim_create_user_command("LspOn", enable_lsp, {}) +vim.api.nvim_create_user_command("UpdateParsers", update_parsers, {}) diff --git a/windows/bin/nvim-update.cmd b/windows/bin/nvim-update.cmd index 974cc95..bcf8b65 100644 --- a/windows/bin/nvim-update.cmd +++ b/windows/bin/nvim-update.cmd @@ -1,2 +1,2 @@ @echo off -nvim --headless -c "lua require[[lazy]].sync({ wait = true })" -c "TSUpdate" -c "qa" +nvim --headless -c "lua require[[lazy]].sync({ wait = true })" -c "UpdateParsers" -c "qa" diff --git a/zsh/zshrc b/zsh/zshrc index fd04552..6f31eaa 100644 --- a/zsh/zshrc +++ b/zsh/zshrc @@ -83,7 +83,7 @@ alias ls='ls -G' nvim-update() { nvim --headless \ -c "lua require[[lazy]].sync({ wait = true })" \ - -c "TSUpdate" \ + -c "UpdateParsers" \ -c "qa" } -- cgit v1.3