I was writing a simple Vim plug-in for a generic code generator called Templaty. The generator can theoretically work with any programming language, and I'd like Vim to automatically apply the correct highlighting.
From experiments, I have noticed Vim automatically loads the correct highlighter if I do something like
set ft=c.templaty. Now, I was wondering if there's a generic way to auto-detect the first part of this string. Right now, I brute-force it by keeping track of a small dictionary of file extensions and their corresponding file type, then doing
exec "setfiletype" (filetype . ".templaty"), but this is far from ideal.
Vim already has
ftdetect-logic, quite possibly with lots of user-defined ones. How would I be able to query this information programmatically?
As suggested in the comments, I could just read
b:current_syntax, but the problem is that the additional
.tply file extension might prevent the default
ftdetect-logic from working. Would it be possible to tell Vim to try detecting the correct file type as if the file was without the