See #358. Add Rustfmt beautifier for Rust language support

This commit is contained in:
Glavin Wiechert 2015-06-06 13:45:56 -03:00
parent 5469dd56bd
commit b0d8d7dd1e
8 changed files with 103 additions and 1 deletions

View File

@ -586,6 +586,15 @@ Indentation size/length (Supported by autopep8)
**Description**: **Description**:
do not fix these errors/warnings (Supported by autopep8) do not fix these errors/warnings (Supported by autopep8)
### Rust - Rustfmt path
**Key**: `rust_rustfmt_path`
**Type**: `string`
**Description**:
Path to rustfmt program (Supported by rustfmt)
### SQL - Indent size ### SQL - Indent size
**Key**: `sql_indent_size` **Key**: `sql_indent_size`
@ -1469,6 +1478,37 @@ Default Beautifier to be used for Ruby
**Description**: **Description**:
Automatically beautify Ruby files on save Automatically beautify Ruby files on save
### Language Config - Rust - Disable Beautifying Language
**Key**: `language_rust_disabled`
**Type**: `boolean`
**Description**:
Disable Rust Beautification
### Language Config - Rust - Default Beautifier
**Key**: `language_rust_default_beautifier`
**Default**: `rustfmt`
**Type**: `string`
**Enum**: `rustfmt`
**Description**:
Default Beautifier to be used for Rust
### Language Config - Rust - Beautify On Save
**Key**: `language_rust_beautify_on_save`
**Type**: `boolean`
**Description**:
Automatically beautify Rust files on save
### Language Config - Sass - Disable Beautifying Language ### Language Config - Sass - Disable Beautifying Language
**Key**: `language_sass_disabled` **Key**: `language_sass_disabled`

View File

@ -0,0 +1,3 @@
fn main() {
println!("hello, world");
}

View File

@ -0,0 +1,3 @@
fn main() {
println!("hello, world");
}

View File

@ -9,7 +9,7 @@ readFile = Promise.promisify(fs.readFile)
module.exports = class Beautifier module.exports = class Beautifier
### ###
### ###
Promise: Promise Promise: Promise

View File

@ -46,6 +46,7 @@ module.exports = class Beautifiers
'prettydiff' 'prettydiff'
'rubocop' 'rubocop'
'ruby-beautify' 'ruby-beautify'
'rustfmt'
'sqlformat' 'sqlformat'
'tidy-markdown' 'tidy-markdown'
'typescript-formatter' 'typescript-formatter'

View File

@ -0,0 +1,27 @@
###
Requires https://github.com/nrc/rustfmt
###
"use strict"
Beautifier = require('./beautifier')
module.exports = class rustfmt extends Beautifier
name: "rustfmt"
options: {
Rust: true
}
beautify: (text, language, options) ->
program = options.rustfmt_path or "rustfmt"
@run(program, [
tmpFile = @tempFile("tmp", text)
], help: {
link: "https://github.com/nrc/rustfmt"
program: "rustfmt"
pathOption: "Rust - Rustfmt Path"
})
.then(=>
@readFile(tmpFile)
)

View File

@ -39,6 +39,7 @@ module.exports = class Languages
"php" "php"
"python" "python"
"ruby" "ruby"
"rust"
"sass" "sass"
"scss" "scss"
"spacebars" "spacebars"

27
src/languages/rust.coffee Normal file
View File

@ -0,0 +1,27 @@
module.exports = {
name: "Rust"
namespace: "rust"
###
Supported Grammars
###
grammars: [
"Rust"
]
###
Supported extensions
###
extensions: [
"rs"
"rlib"
]
options:
rustfmt_path:
type: 'string'
default: ""
description: "Path to rustfmt program"
}