Add ability to read rustfmt.toml

atom-beautifier runs rustfmt in a tmp folder and rustfmt with not pick up
the rustfmt.toml file in any of the crate root folders or its parent folders.
This commit adds the --config-path parameter with the current folder and will
load any rust format in the file's path

Also set the --write-output format to override from the default setting replace.
This will avoid creating an unnecessary backup file tmp source file
This commit is contained in:
sid 2016-01-22 20:40:24 +05:30
parent 1cb84db4f9
commit f5f118a3d2
1 changed files with 10 additions and 0 deletions

View File

@ -14,9 +14,19 @@ module.exports = class Rustfmt extends Beautifier
}
beautify: (text, language, options) ->
# get file path which is the search path for rustfmt.toml as
# the beautifier runs rustfmt in a tmp directory.
# This will pick up any rustfmt.toml defined in the crate root
editor = atom.workspace.getActivePaneItem()
file = editor?.buffer.file
filePath = file?.path
program = options.rustfmt_path or "rustfmt"
@run(program, [
tmpFile = @tempFile("tmp", text)
["--write-mode", "overwrite"]
["--config-path", filePath]
], help: {
link: "https://github.com/nrc/rustfmt"
program: "rustfmt"