I'm using vim with the detectindent script (with ugly hacks and enhancements)[1] for that, it gets this right most of the time if the source file isn't too short, including the number of spaces in case it's space-indented.
[1] https://termbin.com/qzwzy