From f5f118a3d24ec9fca57bbe2c37ef4e791bfd115a Mon Sep 17 00:00:00 2001 From: sid Date: Fri, 22 Jan 2016 20:40:24 +0530 Subject: [PATCH] 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 --- src/beautifiers/rustfmt.coffee | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/beautifiers/rustfmt.coffee b/src/beautifiers/rustfmt.coffee index 6478605..480ab4f 100644 --- a/src/beautifiers/rustfmt.coffee +++ b/src/beautifiers/rustfmt.coffee @@ -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"