return { "nvim-treesitter/nvim-treesitter", branch = "main", build = ":TSUpdate", config = function() local parsers = { "lua", "vim", "vimdoc", "query", "python", "bash", "yaml", "hcl", "terraform", "html", "css", "javascript", "typescript", "tsx", "json", "markdown", "markdown_inline", } -- The `main` branch shells out to the `tree-sitter` CLI to build every -- parser. Without it every single parser fails the same way, which -- floods :messages with one error per parser on every startup — check -- once up front and give a single, actionable warning instead. if vim.fn.executable("tree-sitter") == 0 then vim.notify( "nvim-treesitter: 'tree-sitter' CLI not found on PATH, parsers " .. "won't build (e.g. `brew install tree-sitter-cli` or " .. "`npm install -g tree-sitter-cli`), then :TSUpdate.", vim.log.levels.WARN ) else local ok, err = pcall(function() require("nvim-treesitter").install(parsers) end) if not ok then vim.notify("nvim-treesitter: parser install failed: " .. tostring(err), vim.log.levels.WARN) end end -- Enable highlighting for any buffer whose filetype has an installed -- parser; vim.treesitter.start() is a no-op (caught by pcall) otherwise. vim.api.nvim_create_autocmd("FileType", { pattern = "*", callback = function() pcall(vim.treesitter.start) end, }) end, }