From 4d6b854f4dc852d2cfce334b683216af2cb4fc01 Mon Sep 17 00:00:00 2001 From: Oliver Date: Fri, 13 Mar 2026 15:10:27 +0100 Subject: [PATCH] fix(nvim): refactor treesitter to explicit parser list with deferred install --- nvim/lua/olinpin/plugins/treesitter.lua | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/nvim/lua/olinpin/plugins/treesitter.lua b/nvim/lua/olinpin/plugins/treesitter.lua index 22bcd66..337f9f9 100644 --- a/nvim/lua/olinpin/plugins/treesitter.lua +++ b/nvim/lua/olinpin/plugins/treesitter.lua @@ -3,7 +3,22 @@ return { lazy = false, build = ':TSUpdate', config = function() - -- New nvim-treesitter just installs parsers, Neovim handles highlighting + local ensure_installed = { + "lua", "vim", "vimdoc", "javascript", "typescript", "tsx", + "html", "css", "json", "yaml", "markdown", "bash", "python", + "php", "vue", "dockerfile", "go", "rust", + } + + -- Auto-install missing parsers + vim.defer_fn(function() + for _, lang in ipairs(ensure_installed) do + local ok = pcall(vim.treesitter.language.inspect, lang) + if not ok then + vim.cmd("TSInstall " .. lang) + end + end + end, 100) + -- Start treesitter highlighting for all buffers with a parser vim.api.nvim_create_autocmd("FileType", { callback = function(args)