Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: config to silence executable warnings #242

Merged
merged 1 commit into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading