From f4048b04cd082e643671ee88e8007208085df213 Mon Sep 17 00:00:00 2001 From: Miroito Date: Sun, 19 Apr 2026 11:15:14 +0200 Subject: [PATCH] add hook after treesitter update --- lua/plugins/treesitter.lua | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lua/plugins/treesitter.lua b/lua/plugins/treesitter.lua index 7a710e9..0ac5198 100644 --- a/lua/plugins/treesitter.lua +++ b/lua/plugins/treesitter.lua @@ -1,3 +1,16 @@ +-- This hook checks for a treesitter update, verifies that the plugin +-- is active and runs TSUpdate +-- !! It needs to be defined before vim.pack.add to work +vim.api.nvim_create_autocmd('PackChanged', { + callback = function(ev) + local name, kind = ev.data.spec.name, ev.data.kind + if name == 'nvim-treesitter' and kind == 'update' then + if not ev.data.active then vim.cmd.packadd('nvim-treesitter') end + vim.cmd('TSUpdate') + end + end +}) + vim.pack.add({ { src = 'https://github.com/nvim-treesitter/nvim-treesitter', name = 'treesitter', branch = 'main' }, { src = 'https://github.com/nvim-treesitter/nvim-treesitter-context', name = 'treesitter-context' },