From 5501a8027a263ee345f405f858854ad5e50efea7 Mon Sep 17 00:00:00 2001 From: Crony Akatsuki Date: Tue, 21 Oct 2025 21:04:19 +0200 Subject: [PATCH] feat(pack): run TSUpdate when updating treesitter --- lua/plugins/treesitter.lua | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/lua/plugins/treesitter.lua b/lua/plugins/treesitter.lua index cdf9800..732bc58 100644 --- a/lua/plugins/treesitter.lua +++ b/lua/plugins/treesitter.lua @@ -21,3 +21,21 @@ require("nvim-treesitter.configs").setup({ }, }, }) + +-- run tsupdate when updating nvim-treesitter +vim.api.nvim_create_autocmd('PackChanged', { + desc = 'Handle nvim-treesitter updates', + group = vim.api.nvim_create_augroup('nvim-treesitter-pack-changed-update-handler', { clear = true }), + callback = function(event) + if event.data.kind == 'update' and event.data.spec.name == 'nvim-treesitter' then + vim.notify('nvim-treesitter updated, running TSUpdate...', vim.log.levels.INFO) + ---@diagnostic disable-next-line: param-type-mismatch + local ok = pcall(vim.cmd, 'TSUpdate') + if ok then + vim.notify('TSUpdate completed successfully!', vim.log.levels.INFO) + else + vim.notify('TSUpdate command not available yet, skipping', vim.log.levels.WARN) + end + end + end, +})