nvim-pack / nvim-spectre

Find the enemy and replace them with dark power.
MIT License
1.91k stars 67 forks source link

feat: config to silence executable warnings #242

Open ngscheurich opened 4 days ago

ngscheurich commented 4 days ago

I'm on macOS and, although the sed on my path is GNU sed, I still see the "You need to install gnu sed 'brew install gnu-sed'" warning. This is because the plugin assumes macOS users will be using the Homebrew package manager and thus checks for the gsed executable. While this is a safe assumption for many (most?) macOS users, folks who are using other package managers, have aliased sed to gsed, etc. will see false positives.

I worked around this in a rather simple way, by adding a warn option that the user can simply set to false if they know better than the plugin. From the doc update:

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,
            }
        },
    }
})

A medium-confidence check for GNU sed, e.g. testing for the existence of the --version flag, could be employed but that adds some execution overhead and a bit more complexity than the solution I'm proposing. Thoughts?