From ce6346dff6ae867316127f400b85895cb7fcac07 Mon Sep 17 00:00:00 2001 From: Tom van der Lee Date: Thu, 10 Sep 2026 22:47:08 +0200 Subject: Fixed treesitter.lua --- neovim/.config/nvim/lua/plugins/treesitter.lua | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'neovim/.config/nvim/lua/plugins/treesitter.lua') diff --git a/neovim/.config/nvim/lua/plugins/treesitter.lua b/neovim/.config/nvim/lua/plugins/treesitter.lua index 875500f..37320d4 100644 --- a/neovim/.config/nvim/lua/plugins/treesitter.lua +++ b/neovim/.config/nvim/lua/plugins/treesitter.lua @@ -3,7 +3,7 @@ return { branch = "main", build = ":TSUpdate", config = function() - require("nvim-treesitter").install({ + local parsers = { "lua", "vim", "vimdoc", @@ -21,7 +21,27 @@ return { "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. -- cgit v1.3