rgroli/other.nvim

Pattern matching question

Closed this issue ยท 5 comments

Not sure what I'm doing wrong here ๐Ÿค” Would appreciate any help here ๐Ÿ™‡
I'm trying trying to match /lib/app/entities/account.rb to /lib/some/folders/repositories/account.rb
I tried this but it's not working, what am i missing?

{
  pattern = "/lib/.*/(.*).rb",
  target = "/lib/.*/repositories/%1.rb",
  context = "repository",  
},

Something strange is happening when i spell out the folders though, instead of jumping to the repository folder it creates a new file.
It goes from lib/uplisting/entities/account.rb to /spec/uplisting/entities/account.rb instead of lib/uplisting/rom/repositories/account.rb when i select the "repository" context, not sure why it gets confused here. When i remove my test context mappings it goes correctly to the repositories/account.rb file ๐Ÿค”

My config:

      require("other-nvim").setup({
        rememberBuffers = false,
        mappings = {
          {
            pattern = "/lib/(.*)/(.*).ex",
            target = "/test/%1/%2_test.exs",
            context = "test"
          },
          {
            pattern = "/test/(.*)/(.*)_test.exs",
            target = "/lib/%1/%2.ex",
            context = "test"
          },
          {
            pattern = "/lib/(.*)/(.*).rb",
            target = "/spec/%1/%2_spec.rb",
            context = "test"
          },
          {
            pattern = "/spec/(.*)/(.*)_spec.rb",
            target = "/lib/%1/%2.rb",
            context = "test"
          },
          {
            pattern = "/lib/(.*)/(.*).rb",
            target = "/spec/lib/%1/%2_spec.rb",
            context = "test",
          },
          {
            pattern = "/spec/lib/(.*)/(.*)_spec.rb",
            target = "/lib/%1/%2.rb",
            context = "test"
          },
          {
            pattern = "/lib/uplisting/entities/(.*).rb",
            target = "/lib/uplisting/rom/repositories/%1.rb",
            context = "repository",
          },
        },
      })

Okay, it should not do anything from the test context when the repository context is selected.

I try to reproduce it on my side to find the problem..
Can you tell me, which files in the "test" context are in which folders in your setup?

Regarding your first comment: You cannot use wildcards in the target, that's why it did not work. But that's different from the second issue.

Gotcha regarding the first comment, i can live with that.
Regarding the second:
All of my tests are in the spec folder and there is a spec/uplisting/entities/account_spec.rb file which opens correctly when i pick the test context, when i pick the repository context it opens spec/uplisting/entities/account.rb basically without the _spec.rb at the end

I just added a fix for your problem. The commit automatically closed the issue. If it still remains feel free to reopen.

thanks a lot!!!