Closed emmanueltouzery closed 1 month ago
to be clear, a reproduction would be..
create an empty unsaved file...
type function test() {return 5;}
set ft=typescript
lua require('conform').format()
before the change, nothing would get indented, as prettier says it doesn't recognize the .typescript extension, after the change it works.
EDIT: if you agree with the approach, i can go through the supported formatters for conform, and try to add more entries to this list.
Sure, the approach looks good! The one request would be to pull the map out of the function. I think it makes sense to just put it in its own file, something like ft_to_ext.lua
.
I updated the PR. thinking about it some more, i actually think for many file formats, the extension is not very important.. it's probably mostly important for prettier for instance, which knows how to format many file types.
but presumably it can't hurt to get the file extension right. for many file types there is nothing to do (for instance lua, sql, html, zig..). I added those that I noticed.
LGTM thanks for the PR!
the extension used to be always the file type, be smarter now. For instance prettier wouldn't recognize a
.typescript
extension.