Skip to content

Commit 748f67f

Browse files
authored
Merge pull request #2162 from ollien/fix-ts-install
Check if the buffer is valid when trying to attach TS
2 parents f7b845d + 3711862 commit 748f67f

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

‎init.lua‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -956,6 +956,10 @@ do
956956
local function treesitter_try_attach(buf, language)
957957
-- Check if a parser exists and load it
958958
if not vim.treesitter.language.add(language) then return end
959+
960+
-- Check if the buffer is valid (might not be after install completes)
961+
if not vim.api.nvim_buf_is_valid(buf) then return end
962+
959963
-- Enable syntax highlighting and other treesitter features
960964
vim.treesitter.start(buf, language)
961965

0 commit comments

Comments
 (0)