Some languages have a trim-indent command but don't use it (for no apparent reason). Make them trim trailing spaces when exiting insert mode, like most other languages support scripts do.
See https://github.com/mawww/kakoune/issues/1525#issuecomment-324571751.