Merge pull request #790 from sidred/rustfmt-update

Rust - Add ability to read rustfmt.toml
This commit is contained in:
Glavin Wiechert 2016-02-20 15:30:38 -04:00
commit e74746d32f
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) -> 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" program = options.rustfmt_path or "rustfmt"
@run(program, [ @run(program, [
tmpFile = @tempFile("tmp", text) tmpFile = @tempFile("tmp", text)
["--write-mode", "overwrite"]
["--config-path", filePath]
], help: { ], help: {
link: "https://github.com/nrc/rustfmt" link: "https://github.com/nrc/rustfmt"
program: "rustfmt" program: "rustfmt"