From 1e1b68d633d4bd4faa912ba5f49ab6b8601dc0c9 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre Date: Wed, 25 Oct 2023 15:40:25 +0200 Subject: [PATCH] fix(treesitter): make treesitter queries available at startup. See #1816 Fixes #1858 --- lua/lazyvim/plugins/treesitter.lua | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lua/lazyvim/plugins/treesitter.lua b/lua/lazyvim/plugins/treesitter.lua index 3277ef83..e66725c0 100644 --- a/lua/lazyvim/plugins/treesitter.lua +++ b/lua/lazyvim/plugins/treesitter.lua @@ -7,6 +7,15 @@ return { version = false, -- last release is way too old and doesn't work on Windows build = ":TSUpdate", event = { "LazyFile", "VeryLazy" }, + init = function(plugin) + -- PERF: add nvim-treesitter queries to the rtp and it's custom query predicates early + -- This is needed because a bunch of plugins no longer `require("nvim-treesitter")`, which + -- no longer trigger the **nvim-treeitter** module to be loaded in time. + -- Luckily, the only thins that those plugins need are the custom queries, which we make available + -- during startup. + require("lazy.core.loader").add_to_rtp(plugin) + require("nvim-treesitter.query_predicates") + end, dependencies = { { "nvim-treesitter/nvim-treesitter-textobjects",