This format function is great to use on any languages not supported by your current LSP or when you are trying to pass custom arguments.
This example shows how dart format
can be used to reformat the current buffer (so
the file save state is irrelevant), replace the buffer with the new contents, and
put the cursor back in position.
We prevent the need to escape any variables or tokens inside by using bash heredoc
so there should be no problems with \n
or $
and the likes.
If there are errors, it won't do the replacement, and show the error in the nvim error log.
The other examples weren't tested, but they are there to get you started, maybe.