rgroli / other.nvim

Open alternative files for the current buffer
MIT License
390 stars 30 forks source link

Pattern matching issues #54

Open alexgorbatchev opened 4 months ago

alexgorbatchev commented 4 months ago

Odd issue in pattern matching:

rgroli commented 4 months ago

Try removing the leading part completely. (starting with "/") That should do the trick.

cheers

alexgorbatchev commented 4 months ago

This config causes my neovim (0.10) to freeze for about a minute on a macbook pro m3

          {
            pattern = "([^.]+).(tsx?)$",
            target = {
              { target = "**/%1.test.%2", context = "test" },
              { target = "**/%1.stories.%2", context = "stories" },
            },
          },

I have to use this, which works, but not ideal, i would prefer not to have src/ prefix. The /.*/([^.]+).(tsx?)$ also causes neovim to freeze

          {
            pattern = "src/.*/([^.]+).(tsx?)$",
            target = {
              { target = "**/%1.test.%2", context = "test" },
              { target = "**/%1.stories.%2", context = "stories" },
            },
          },

my full config is

      require("other-nvim").setup({
        rememberBuffers = false,
        showMissingFiles = false,
        mappings = {
          {
            pattern = "src/.*/([^.]+).(tsx?)$",
            target = {
              { target = "**/%1.test.%2", context = "test" },
              { target = "**/%1.stories.%2", context = "stories" },
            },
          },
          {
            pattern = "src/.*/([^.]+).test.(tsx?)$",
            target = {
              { target = "**/%1.%2", context = "source" },
              { target = "**/%1.stories.%2", context = "stories" },
            },
          },
          {
            pattern = "src/.*/([^.]+).stories.(tsx?)$",
            target = {
              { target = "**/%1.%2", context = "source" },
              { target = "**/%1.test.%2", context = "test" },
            },
          },
        },
      })