From bd5406e3f85ff989325f9da7f752a032ede3d5cf Mon Sep 17 00:00:00 2001 From: Nick Krichevsky Date: Tue, 8 Sep 2026 14:09:05 -0400 Subject: [PATCH] Check if the buffer is valid when trying to attach TS --- init.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/init.lua b/init.lua index 99763667..5572e462 100644 --- a/init.lua +++ b/init.lua @@ -954,6 +954,9 @@ do ---@param buf integer ---@param language string local function treesitter_try_attach(buf, language) + -- Check if the buffer is valid (might not be after install completes) + if not vim.api.nvim_buf_is_valid(buf) then return end + -- Check if a parser exists and load it if not vim.treesitter.language.add(language) then return end -- Enable syntax highlighting and other treesitter features