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"