Commit f672525
committed
Help projectionist find .projections.json in new directories
I have an auto-mkdir thing for writing files in directories that don't exist, and projection templates are not applied to files in non-existent directories (and actually, vim-projectionist just fails to find .projections.json in this case). They are if I `mkdir` first though.
Example:
**Projection**
```
{
"foo/*.js": {
"template": [
"blah"
]
}
}
```
If I do `vim foo/bar.js` the template is used; if I do `mkdir foo/bar/ && vim foo/bar/baz.js` the template is used. But if I do `vim foo/bar/baz.js` by itself I don't get the template.
Here's why it matters: angular and react and some other frameworks advocate a directory-per-component structure, so any new component is in a new directory. Your structure ends up looking like:
```
components/
foo/
foo.js
foo.html
foo.test.js
```
so every time you create a new component you're creating a new directory. Which means I either _never_ get the benefit of auto-mkdir (and have to type `mkdir` every time . . . I know, I know, first world problems) or I _never_ get the benefit of a projection template.
This turned out to be because `expand('<afile>:p')` doesn't result in an absolute path in non-existent directories. This change fixes it by detecting non-absolute paths and prefixing them with cwd.
Thoughts?1 parent ea1347b commit f672525
1 file changed
+6
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
72 | 77 | | |
73 | 78 | | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
| 79 | + | |
79 | 80 | | |
80 | 81 | | |
81 | 82 | | |
| |||
0 commit comments