From 5daf4979cf64ae2d5391bcfe3bc9db8e08e5c617 Mon Sep 17 00:00:00 2001 From: "N. G. Scheurich" Date: Wed, 26 Jun 2024 19:36:10 -0500 Subject: [PATCH] feat: config to silence executable warnings --- doc/spectre.txt | 16 ++++++++++++++++ lua/spectre/config.lua | 2 ++ lua/spectre/init.lua | 6 +++--- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/doc/spectre.txt b/doc/spectre.txt index 7fac04d..f9fbb98 100644 --- a/doc/spectre.txt +++ b/doc/spectre.txt @@ -273,6 +273,7 @@ default settings. icon="[I]", desc="ignore case" }, + warn = true, } }, -- call rust code by nvim-oxi to replace @@ -290,6 +291,7 @@ default settings. ['sd'] = { cmd = "sd", options = { }, + warn = true, }, }, default = { @@ -314,6 +316,20 @@ default settings. } }) < +Warnings are emitted based on your operating system and chosen executables. If +you find one of these warnings to be in error, you may silence it by setting +the respective `warn` key. For example, to silence GNU sed warnings: + +> + require('spectre').setup({ + replace_engine={ + ['sed']={ + warn = false, + } + }, + } + }) +> CUSTOM FUNCTIONS ~ diff --git a/lua/spectre/config.lua b/lua/spectre/config.lua index 9e54776..85ab105 100644 --- a/lua/spectre/config.lua +++ b/lua/spectre/config.lua @@ -189,6 +189,7 @@ local config = { desc = 'ignore case', }, }, + warn = true, }, ['oxi'] = { cmd = 'oxi', @@ -204,6 +205,7 @@ local config = { ['sd'] = { cmd = 'sd', options = {}, + warn = true, }, }, default = { diff --git a/lua/spectre/init.lua b/lua/spectre/init.lua index bce86fd..471ce5c 100644 --- a/lua/spectre/init.lua +++ b/lua/spectre/init.lua @@ -45,20 +45,20 @@ M.check_replace_cmd_bins = function() if state.user_config.default.replace.cmd == 'sed' then if vim.loop.os_uname().sysname == 'Darwin' then config.replace_engine.sed.cmd = 'gsed' - if vim.fn.executable('gsed') == 0 then + if vim.fn.executable('gsed') == 0 and state.user_config.replace_engine.sed.warn then print("You need to install gnu sed 'brew install gnu-sed'") end end if vim.loop.os_uname().sysname == 'Windows_NT' then - if vim.fn.executable('sed') == 0 then + if vim.fn.executable('sed') == 0 and state.user_config.replace_engine.sed.warn then print("You need to install gnu sed with 'scoop install sed' or 'choco install sed'") end end end if state.user_config.default.replace.cmd == 'sd' then - if vim.fn.executable('sd') == 0 then + if vim.fn.executable('sd') == 0 and state.user_config.replace_engine.sd.warn then print("You need to install or build 'sd' from: https://github.com/chmln/sd") end end