Comments (10)
Yes, you would do it this way
{
pattern = 'src/some/(.*)/(.*).ext',
target = 'test/a/%1/%2.spec.ext',
},
from other.nvim.
Hi,
to be seable to sarch in subdirectories in the target you must use the recursive glob thing "**".
So basically this should work:
{
pattern = "src/.*/(.*).ext",
target = "test/**/%1.spec.ext",
},
and also the other way...
{
pattern = "test/.*/(.*).spec.ext",
target = "src/**/%1.ext",
},
Hope that helps 😄
from other.nvim.
exactly 😄 Closing this for now..
from other.nvim.
Hey 👋🏾
Thanks for the reply. 🙏🏾
But wouldn't that now match the first matching group of the pattern in the target too? Because that's what I have and it is not working. I would like to loosen the pattern and find more potential results. So I can specify fewer and less concrete targets.
Trying to describe this in some points:
- I define a folder where source files are inside
- I only care about the file name, the path "in-between" doesn't matter
- I define a folder where all kind of test files are inside
- in this folder I try to find a file with a matching name plus some additional stuff
Having the above pattern again:
pattern = 'src/.*/(.*).ext',
target = 'test/.*/%2.spec.ext',
I want these to match:
./src/foo/file.ext
-> ./test/what/ever/else/file.spec.ext
or ./test/poop/file.spec.ext
./src/bar/baz/file.ext
-> ./test/file.ext
or ./test/holy/shit/that/is/long/file.spec.ext
Was that better explained? 🙈
from other.nvim.
Nice. That helped. Thank you very much! 🙏🏾
from other.nvim.
A final question if I may ask: how can I make it case insensitive? 🙈
E.g. if the source file name would be FooBar.ext
to also match fooBar.spec.ext
.
A transformer does not do I guess.
from other.nvim.
Sure, but actually this should just work.. the search is case-insensitive..
from other.nvim.
But not the matching of the captured group right? Because it definitely doesn't work for me. And I thought that's also the reason for the transformers? 🤔
from other.nvim.
@weilbith okay, let's narrow this issue down.. 😄
I have the following config:
mappings = {
{
pattern = "src/.*/(.*).ext",
target = "test/**/%1.spec.ext",
},
{
pattern = "test/.*/(.*).spec.ext",
target = "src/**/%1.ext",
},
},
With this I am able to switch back and forth for the following files:
/fixtures/uppercase-lowercase/src/foo/file.ext
/fixtures/uppercase-lowercase/test/what/ever/else/file.spec.ext
and also
/fixtures/uppercase-lowercase/src/foo/FooBar.ext
/fixtures/uppercase-lowercase/test/what/ever/else/fooBar.spec.ext
does this work for you?
The transformers are used to transform a captured group before it is used in the target (which is then searched with glob). Although the repo example shows the lowercase transformer, it's just to demonstrate an easy use case. I never needed to use this in real life. They are generally used to transform between camel to kebap or removing some suffixes or prefixes.
I am on a mac, where you don't need to care about case sensitivity in filepaths by default. Maybe that could be the problem? What system are you using?
from other.nvim.
Hey 👋🏾
Sorry, I was on vacation without my laptop and thereby couldn't try it out.
Now I did. Thanks for your exact example. I literally created exactly the folders and files you have described and also the exact mappings. And yes, this still doesn't work for me for the second case.
I am on a mac, where you don't need to care about case sensitivity in filepaths by default. Maybe that could be the problem? What system are you using?
Very interesting. I didn't know about that. I'm working with Linux. So that could be it. But I see you added a testcase for this. I guess your CI is not running with MacOS, right?
from other.nvim.
Related Issues (20)
- Not work on next.js & sveltekit HOT 11
- How to contribute
- Let :Other accept file path as an argument HOT 2
- Mapping the current directory HOT 3
- Suggesting repeated other spec files HOT 1
- Suggestion: Open as tab HOT 1
- Suggestion: Support for Angular Services HOT 1
- Not working with negative lookbehind regex pattern HOT 1
- [SUGGESTION] c{,pp} header and source files HOT 1
- Pattern matching not working? HOT 1
- Command to open the file picker without clearing the internal reference HOT 1
- Question: What's the syntax used in target field? HOT 1
- Use custom highlight groups HOT 1
- If `filePickerBeforeShow` returns false or an empty table, do nothing HOT 1
- Keep default openCommand when invoking `OtherSplit` et al. and selecting in picker HOT 2
- Question: do not specify match group in 'target' HOT 1
- Expose local findOther function as API HOT 4
- [Feature request]: Allow setting the shortcut char on the mapping HOT 1
- [Feature] Add spec patterns to default rails mappings HOT 1
- Is it possible to go "back" to the "main" file? HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from other.nvim.