vim-template icon indicating copy to clipboard operation
vim-template copied to clipboard

More control over global template file name prefixes

Open benlindsay opened this issue 8 years ago • 4 comments

I want to be able to have access to the shipped templates in your plugin, but I'd also like to have my own global templates that look like ~/.vim/templates/ of the form template.ext instead of =template=.ext. I just changed. For me it works fine to just change g:templates_global_name_prefix to g:templates_name_prefix on line 516 and just change g:templates_name_prefix in my .vimrc, but it might be better to just prevent g:templates_global_name_prefix from setting the expected prefix for the shipped templates since we don't need to change file names of your shipped templates.

benlindsay avatar Jun 29 '16 13:06 benlindsay

Hm, yes I think this makes sense. Perhaps it can be done in such a way that it doesn't break everyone's configs.

muff1nman avatar Jul 14 '16 03:07 muff1nman

I think that if the expected prefix for the shipped templates is just hard-coded as =template= and prevented from being changed by the user, no one's configs would break. I doubt anyone changes the names of the shipped templates inside the repo.

benlindsay avatar Jul 14 '16 03:07 benlindsay

Agreed. That would be a safe bet, but actually looking over the current setup, this might be a good opportunity to cleanup the variable names to make them more clear.

What about the following:

  • g:templates_name_prefix -> g:templates_pwd_prefix
    • Same behavior of controlling prefix of templates within pwd and parents
  • g:templates_global_name_prefix -> g:templates_global_prefix
    • Would only control user defined template prefixes from g:templates_directory
  • g:templates_builtin_prefix
    • New variable to define builtin prefix. Doesn't necessarily need to be exposed, but I don't see it hurting anything to allow it to be controlled

And then to make it not break configs, we would still look for the two old variables and set the new ones automatically.

Thoughts?

muff1nman avatar Jul 14 '16 04:07 muff1nman

I personally don't think the new names proposed for the first two increase clarity enough to be worth breaking people's configs. I would just recommend adding the g:templates_builtin_prefix variable with =template= as the default value. To be honest though, I already switched to vim-skeleton because, even though it doesn't have the nice builtin templates like vim-template, I found it easier to customize for my purposes.

benlindsay avatar Jul 14 '16 23:07 benlindsay