Skip to content

Commit

Permalink
Merge pull request #242 from ngscheurich/allow-skip-sed-check
Browse files Browse the repository at this point in the history
feat: config to silence executable warnings
  • Loading branch information
EpsilonKu authored Jul 8, 2024
2 parents 49fae98 + 5daf497 commit 9a28f92
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
16 changes: 16 additions & 0 deletions doc/spectre.txt
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ default settings.
icon="[I]",
desc="ignore case"
},
warn = true,
}
},
-- call rust code by nvim-oxi to replace
Expand All @@ -290,6 +291,7 @@ default settings.
['sd'] = {
cmd = "sd",
options = { },
warn = true,
},
},
default = {
Expand All @@ -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 ~
Expand Down
2 changes: 2 additions & 0 deletions lua/spectre/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ local config = {
desc = 'ignore case',
},
},
warn = true,
},
['oxi'] = {
cmd = 'oxi',
Expand All @@ -204,6 +205,7 @@ local config = {
['sd'] = {
cmd = 'sd',
options = {},
warn = true,
},
},
default = {
Expand Down
6 changes: 3 additions & 3 deletions lua/spectre/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 9a28f92

Please # to comment.