-
-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Help projectionist find .projections.json in new directories #105
base: master
Are you sure you want to change the base?
Conversation
Off the top of my head, this will have unintended consequences for unnamed buffers, URLs (ranging from My larger thoughts are that auto-mkdir just can't be done well in practice. If you do it on My preferred solution to this is to have a command or command variant for creating the directory and file in one go. For example, in rails.vim, you can do |
Oh look what I found https://github.com/tpope/vim-projectionist/blob/9eff21e1bcb2db6fb5aadbd45886a98d2a397e59/autoload/projectionist.vim#L688. Guess I added support after all. |
Somehow that link isn't going to the right thing for me. When I follow it, the version of |
Is this what you're referring to? https://github.com/tpope/vim-projectionist/blob/master/autoload/projectionist.vim#L601-L603 |
Yes that. |
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?
7f6b029
to
f672525
Compare
Help projectionist find .projections.json in new directories * github.com:tpope/vim-projectionist: 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
If I do
vim foo/bar.js
the template is used; if I domkdir foo/bar/ && vim foo/bar/baz.js
the template is used. But if I dovim 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:
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?