nvim-pack / nvim-spectre

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

add support to pcre2 operations #225

Closed n1ckisthereu closed 2 months ago

n1ckisthereu commented 2 months ago

Hello everyone, everything good? I would like to propose a simple change in the way "oxi" implements regex, I recently came across a problem, I need to replace the import of some libraries for a specific pattern, but I only managed to get a satisfactory regex using an operator called negative lookahead operator, although ripgrep already has support if we use the --pcre2 flag, sed and not even oxi supports these operators by default, by researching a little it is possible to see that oxy uses the rust regex lib, however, it does not support pcre2 operations, but I found a call fancy_regex that supports "pcre2" operators which is very similar to regex, and I just made a small change in the "matchstr" function and now it is possible for operators to use pcre2 without any problem , ripgrep already supports this type of operator, it is very simple to support this implementation in the plugin configuration, here is an example:

return {
  "nvim-pack/nvim-spectre",
  opts = {
    default = {
      replace = {
        cmd = "oxi",
      },
    },
    find_engine = {
      ["rg"] = {
        cmd = "rg",
        args = {
          "--pcre2",
          "--color=never",
          "--no-heading",
          "--with-filename",
          "--line-number",
          "--column",
        },
      },
    },
  },
}
EpsilonKu commented 2 months ago

Can you add "--pcre2" argument to README? Also wth is ur pfp, lmao? Also, check stylua

n1ckisthereu commented 2 months ago

hey brow, I apologize for the delay in completing a simple task, I was busy, but I made the adjustments.

This pfp is a joke from college, I ended up forgetting to take it off, lmao 🤣