Skip to content

Add Formatting plugin

Waqar Ahmed requested to merge work/formatting into master

This is a new plugin that can format code in two ways:

  • Automatic formatting on save
  • Via a single exposed action named "Format Document"

Supported formatters

  • clang-format
  • prettier
  • dartfmt
  • rustfmt
  • xmllint for xml
  • jq for json
  • go fmt

Compared to 'External Tools', this is a lot nicer to use in my opinion because

  • it provides a single interface to do formatting
  • it applies formatting as a patch on top of the document which helps retaining the undo history and provides an easy way to undo the changes quickly.
  • has more control, for e.g., with clang-format it is able to format only the changed lines of a document and not the whole document

Feedback welcome.

Edited by Waqar Ahmed

Merge request reports