diff --git a/README.md b/README.md index 4b60efd..b07e555 100644 --- a/README.md +++ b/README.md @@ -60,7 +60,7 @@ Or Settings/Preferences ➔ Packages ➔ Search for `atom-beautify` - [x] [Objective-C](https://github.com/Glavin001/atom-beautify/issues/57) - Requires [Uncrustify](http://sourceforge.net/projects/uncrustify/) - [x] [D](https://github.com/Glavin001/atom-beautify/issues/57) - - Requires [Uncrustify](http://sourceforge.net/projects/uncrustify/) + - Requires [Uncrustify](http://sourceforge.net/projects/uncrustify/) or [dfmt](https://github.com/Hackerpilot/dfmt) - [x] [Fortran](https://github.com/Glavin001/atom-beautify/issues/300) - Requires [GNU Emacs](http://www.gnu.org/software/emacs/) - [x] [Pawn](https://github.com/Glavin001/atom-beautify/issues/57) diff --git a/examples/nested-jsbeautifyrc/d/expected/test.d b/examples/nested-jsbeautifyrc/d/expected/test.d new file mode 100644 index 0000000..57e453f --- /dev/null +++ b/examples/nested-jsbeautifyrc/d/expected/test.d @@ -0,0 +1,10 @@ +class Test +{ + private int member; + public auto func(string str) + { + import std.stdio; + + writeln("Hello world !"); + } +} diff --git a/examples/nested-jsbeautifyrc/d/original/test.d b/examples/nested-jsbeautifyrc/d/original/test.d new file mode 100644 index 0000000..40d559b --- /dev/null +++ b/examples/nested-jsbeautifyrc/d/original/test.d @@ -0,0 +1,5 @@ +class Test{ +private int member ; + public auto func ( string str ) + { + import std.stdio; writeln("Hello world !");}} diff --git a/spec/beautify-languages-spec.coffee b/spec/beautify-languages-spec.coffee index 293dc45..d0d43c9 100644 --- a/spec/beautify-languages-spec.coffee +++ b/spec/beautify-languages-spec.coffee @@ -21,7 +21,7 @@ describe "BeautifyLanguages", -> # Activate all of the languages allLanguages = [ - "c", "coffee-script", "css", "html", + "c", "coffee-script", "css", "d", "html", "java", "javascript", "json", "less", "mustache", "objective-c", "perl", "php", "python", "ruby", "sass", "sql", "svg", diff --git a/src/beautifiers/dfmt.coffee b/src/beautifiers/dfmt.coffee new file mode 100644 index 0000000..8571ceb --- /dev/null +++ b/src/beautifiers/dfmt.coffee @@ -0,0 +1,17 @@ +### +Requires [dfmt](https://github.com/Hackerpilot/dfmt) +### +"use strict" +Beautifier = require('./beautifier') + +module.exports = class Dfmt extends Beautifier + name: "dfmt" + + options: { + D: true + } + + beautify: (text, language, options) -> + @run("dfmt", [ + @tempFile("input", text) + ]) diff --git a/src/beautifiers/index.coffee b/src/beautifiers/index.coffee index d1bbc77..f0f6acb 100644 --- a/src/beautifiers/index.coffee +++ b/src/beautifiers/index.coffee @@ -38,6 +38,7 @@ module.exports = class Beautifiers extends EventEmitter 'coffee-formatter' 'coffee-fmt' 'clang-format' + 'dfmt' 'elm-format' 'htmlbeautifier' 'csscomb' diff --git a/src/languages/d.coffee b/src/languages/d.coffee index 85ffa77..0e89e3d 100644 --- a/src/languages/d.coffee +++ b/src/languages/d.coffee @@ -16,6 +16,8 @@ module.exports = { extensions: [ ] + defaultBeautifier: "dfmt" + options: configPath: type: 'string'