From 70921baa47aac8aaf35e7a87eccf3293cee96d11 Mon Sep 17 00:00:00 2001 From: Simon Date: Mon, 19 Oct 2026 01:34:00 -0700 Subject: [PATCH] Compile treesitter parsers with MinGW gcc on Windows On Windows the tree-sitter CLI looks for MSVC and doesn't try a gcc on PATH, so with the README's MinGW setup every parser failed with "Failed to execute the C compiler ... program not found". CI didn't notice because its runner has MSVC. Point it at gcc (CC=gcc) when there's no cl on PATH and CC isn't set. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> --- README.md | 2 +- lua/simonkdev/lazy/treesitter.lua | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b674e6c..f0a45cc 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Other than small retouch the setup is virtually identitcal to Josean's setup, ch ## Requirements - Neovim 0.12 or later. -- A C compiler on `PATH` (e.g. gcc from MinGW) to build treesitter parsers and telescope-fzf-native. nvim-treesitter also needs the `tree-sitter` CLI, which Mason installs; on a fresh machine parsers install once Mason has it. +- A C compiler on `PATH` (e.g. gcc from MinGW) to build treesitter parsers and telescope-fzf-native. Without MSVC, the config points tree-sitter at gcc by setting `CC`. nvim-treesitter also needs the `tree-sitter` CLI, which Mason installs; on a fresh machine parsers install once Mason has it. - For Rust, rust-analyzer from your toolchain: `rustup component add rust-analyzer`. rustaceanvim starts it (and Mason's codelldb for debugging); don't install rust-analyzer through Mason. - For C#, the .NET 10 SDK, which the pinned Roslyn needs to install and run. Mason installs Roslyn (the language server VS Code's C# extension uses) when `dotnet` is on `PATH`, and netcoredbg. `dc` in a C# file offers *Build and debug a project*: pick a runnable project from the solution, and it builds it (build errors go to quickfix) and starts the debugger on its output. diff --git a/lua/simonkdev/lazy/treesitter.lua b/lua/simonkdev/lazy/treesitter.lua index b762323..b977f4f 100644 --- a/lua/simonkdev/lazy/treesitter.lua +++ b/lua/simonkdev/lazy/treesitter.lua @@ -41,6 +41,14 @@ return { config = function(_, opts) local ts = require("nvim-treesitter") + -- On Windows the tree-sitter CLI looks for MSVC and ignores a MinGW gcc on PATH ("Failed to execute the C + -- compiler"), so point it at gcc when there's no MSVC. + if vim.fn.has("win32") == 1 and not vim.env.CC and vim.fn.executable("cl") == 0 then + if vim.fn.executable("gcc") == 1 then + vim.env.CC = "gcc" + end + end + -- A no-op for installed parsers. On a fresh machine the CLI shows up once Mason has installed it. local function install() if vim.fn.executable("tree-sitter") == 1 then