Skip to content

Commit

Permalink
Moved replace_cmd check for existing bin for sed and added a check fo…
Browse files Browse the repository at this point in the history
…r sd
  • Loading branch information
Zananok committed Mar 22, 2024
1 parent 31f62d7 commit f601fc8
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 12 deletions.
12 changes: 0 additions & 12 deletions lua/spectre/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -217,16 +217,4 @@ local config = {
open_template = {},
}

if vim.loop.os_uname().sysname == 'Darwin' then
config.replace_engine.sed.cmd = 'gsed'
if vim.fn.executable('gsed') == 0 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
print("You need to install gnu sed with 'scoop install sed' or 'choco install sed'")
end
end
return config
24 changes: 24 additions & 0 deletions lua/spectre/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,30 @@ M.setup = function(cfg)
state.options[opt] = true
end
require('spectre.highlight').set_hl()
M.check_replace_cmd_bins()
end

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
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
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
print("You need to install or build 'sd' from: https://github.com/chmln/sd")
end
end
end

M.open_visual = function(opts)
Expand Down

0 comments on commit f601fc8

Please sign in to comment.