Open vinibispo opened 2 years ago
I was considering completely redesigning the implementation. Let me draft something here before we start writing code!
Two hardcoded arrays, one for where to find the app/lib source code {"app", "lib", ""}
and another one to find testes, {"test", "spec"}
. Basically, we take the path of the current file, and use these locations to:
app/model/whatever.rb
to spec/model/whatever_spec.rb
)In theory, it looks fine, but every now and then I find edge cases.
This will be a table like:
{
path: "app/models/whatever.rb",
parts: {"models", "whatever"},
}
Steps to build it:
Step | App example | Test example |
---|---|---|
Start with a path | app/models/whatever.rb |
spec/models/whatever_spec.rb |
Drop extension | app/models/whatever |
spec/models/whatever_spec |
Drop default directory names such as lib , app , test , spec |
models/whatever |
models/whatever_spec |
Drop default test suffixes | models/whatever |
models/whatever |
Convert to an array | {"models", "whatever"} |
{"models", "whatever"} |
Probably at first use, we can walk the project directory and create these tables for every Ruby file in the project. This can take a while, but we cache.
:RubyAlternate
app/controllers/login.rb
would probably match with spec/requests/login_spec.rb
)nil
I think I'm going to work on this in the following weeks
Or… maybe… we leave it to a 3rd party https://github.com/rgroli/other.nvim
Step
@cuducos