Kak's formatcmd implementation for ktlint in kotlin.kak language support

Update: Currently I do not have the time to work on this issue will come back to it in a couple of months and restructure this help request with a little more information and accuracy.

Hi all,
I’m implementing ktlint for kotlin language support plugin and could do with some feedback on kak’s formatcmd command and my application of it.

Worst fear, the destruction of someone’s hard work on any open; buffers, clients, files, and directories. Please see the pictures below any other information you may need just let me know.

ktlint - Main.kt for complete list of command line arguments.

Without ending the command with “2> /dev/null”, kak writes stderr to debug buffer of the checkstyle.xml path.

ktlint output redirected to kak’s debug buffer:

output to xml looks like:

And the received info from kak on the current buffer:
Output to kak debug buffer was accomplished by:

Add if needed the inline flag --reporter=checkstyle,output=file-name.xml

Implementation via:
hook global WinSetOption filetype=kotlin %{ … }

Note: ktlint always defaults to pwd and looks for the file their. If formatcmd is run from alternate directory to the source file it wipes the files contents. shift+u will retrieve its contents.

Thanks in advance guys.