From 029ae8e0c3ba792950d48ea1e4d9af339318ea06 Mon Sep 17 00:00:00 2001 From: Marc Jakobi Date: Mon, 29 Jul 2024 18:44:54 +0200 Subject: [PATCH] fix(rustc): windows support --- CHANGELOG.md | 1 + lua/rustaceanvim/commands/rustc_unpretty.lua | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 71caaf54..7bbac496 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Neotest: One test failure caused all succeeding tests to be marked as failed when using cargo-nextest 0.9.7 [[#460](https://github.com/mrcjkb/rustaceanvim/issues/460)]. - Neotest: Disable ansi colour coding in output to ensure output can be parsed. +- `Rustc unpretty`: Support Windows. ## [5.1.0] - 2024-07-27 diff --git a/lua/rustaceanvim/commands/rustc_unpretty.lua b/lua/rustaceanvim/commands/rustc_unpretty.lua index 25b80bf3..938a1e58 100644 --- a/lua/rustaceanvim/commands/rustc_unpretty.lua +++ b/lua/rustaceanvim/commands/rustc_unpretty.lua @@ -92,9 +92,15 @@ local function handler(sc) vim.api.nvim_buf_set_lines(latest_buf_id, 0, 0, false, lines) end +---@return boolean +local function has_tree_sitter_rust() + return #api.nvim_get_runtime_file('parser/rust.so', true) > 0 + or require('rustaceanvim.shell').is_windows() and #api.nvim_get_runtime_file('parser/rust.dll', true) > 0 +end + ---@param level rustaceanvim.rustcir.level function M.rustc_unpretty(level) - if #api.nvim_get_runtime_file('parser/rust.so', true) == 0 then + if not has_tree_sitter_rust() then vim.notify("a treesitter parser for Rust is required for 'rustc unpretty'", vim.log.levels.ERROR) return end