rgroli/other.nvim

Idea for improvement: define names for mappings

Closed this issue · 1 comments

If I have multiple targets for one pattern, but the target files have the same file name, I cannot differentiate them in the file picker.

Example:

pattern: (.*)/views/(.*).html
targets: %1/models/%2.php, %1/controllers/%2.php

Directory structure:

views/
    user.html
models/
    user.php
controllers/
    user.php

If I'm in the view and call :Other, than I see a file picker with the following files:

user.php
user.php

So I don't know which file is the model and which one is the controller.

So an idea would be to define a name in the mapping like this:

{
    pattern = "(.*)/views/(.*).html",
    target = "%1/models/%2.php",
    name = "Model"
},
{
    pattern = "(.*)/views/(.*).html",
    target = "%1/models/%2.php",
    name = "Controller"
}

And the file picker could than use the name and show it next to the file like

user.php / Model
user.php / Controller

This is now implementied using the context property of the mapping. :)