tibabit / vim-templates

create files from templates
https://tibabit.github.io/vim-templates/
MIT License
73 stars 30 forks source link

Added support for using filetype instead of extension (disabled by default) #17

Closed GiancarloAparicio closed 3 years ago

GiancarloAparicio commented 3 years ago

By default it behaves normal taking the file extension, but in those cases as file.blade.php or with the modified filetype (file.jsx -> javascriptreact), it would be enough to activate the variable 'vt_use_filetype', so that it takes the file: file.blade.php -> blade.template, file.jsx -> javascriptreact.template

let g:vt_use_filetype = 1
tibabit commented 3 years ago

This may not work for all scenarios, because sometimes we may not have filetype defined for the file we are working on. E.g. for sample.test.js filetype will be Javascript but people might want to initialize it with different template since it is a test file. I would suggest you to look at the fileparts. Right now it only considers sample.test.js (file name with extension) and js (file extension). We can modify it to also consider test.js. So basically all substring starting with a dot and the substring will have decreasing priority from left to right.

GiancarloAparicio commented 3 years ago

This may not work for all scenarios, because sometimes we may not have filetype defined for the file we are working on. E.g. for sample.test.js filetype will be Javascript but people might want to initialize it with different template since it is a test file. I would suggest you to look at the fileparts. Right now it only considers sample.test.js (file name with extension) and js (file extension). We can modify it to also consider test.js. So basically all substring starting with a dot and the substring will have decreasing priority from left to right.

If you are right, I focus on my problem with the filetype that not my account that the general solution is to handle all extensions or substrings separate and execute them in order of priority