From ec5071a70d3662f99a8aa3dd0f73145e93bb4d7d Mon Sep 17 00:00:00 2001 From: Mark Baas Date: Wed, 25 Nov 2015 17:38:57 -0400 Subject: [PATCH 1/2] added erlang support --- README.md | 2 ++ src/beautifiers/erl_tidy.coffee | 26 ++++++++++++++++++++++++++ src/beautifiers/index.coffee | 1 + src/languages/erlang.coffee | 21 +++++++++++++++++++++ src/languages/index.coffee | 1 + 5 files changed, 51 insertions(+) create mode 100644 src/beautifiers/erl_tidy.coffee create mode 100644 src/languages/erlang.coffee diff --git a/README.md b/README.md index 5eb559b..90a14ad 100644 --- a/README.md +++ b/README.md @@ -70,6 +70,8 @@ Or Settings/Preferences ➔ Packages ➔ Search for `atom-beautify` - [x] [TypeScript](https://github.com/Glavin001/atom-beautify/issues/49) - [x] [Haskell](https://github.com/Glavin001/atom-beautify/issues/628) - Requires [stylish-haskell](https://github.com/jaspervdj/stylish-haskell) +- [x] [Erlang]() + - Requires erlang syntax_tools to be installed ## Usage diff --git a/src/beautifiers/erl_tidy.coffee b/src/beautifiers/erl_tidy.coffee new file mode 100644 index 0000000..1bf4076 --- /dev/null +++ b/src/beautifiers/erl_tidy.coffee @@ -0,0 +1,26 @@ +### +Requires https://github.com/hhatto/autopep8 +### + +"use strict" +Beautifier = require('./beautifier') + +module.exports = class ErlTidy extends Beautifier + + name: "erl_tidy" + + options: { + Erlang: true + } + + beautify: (text, language, options) -> + tempFile = undefined + @tempFile("input", text).then((path) => + tempFile = path + @run("erl", [ + ["-eval", 'erl_tidy:file("' + tempFile + '")'] + ["-noshell", "-s", "init", "stop"] + ]) + ).then(=> + @readFile(tempFile) + ) diff --git a/src/beautifiers/index.coffee b/src/beautifiers/index.coffee index 143fef3..6da13e2 100644 --- a/src/beautifiers/index.coffee +++ b/src/beautifiers/index.coffee @@ -57,6 +57,7 @@ module.exports = class Beautifiers extends EventEmitter 'tidy-markdown' 'typescript-formatter' 'yapf' + 'erl_tidy' ] ### diff --git a/src/languages/erlang.coffee b/src/languages/erlang.coffee new file mode 100644 index 0000000..28995ab --- /dev/null +++ b/src/languages/erlang.coffee @@ -0,0 +1,21 @@ +module.exports = { + + name: "Erlang" + namespace: "erlang" + fallback: [] + + ### + Supported Grammars + ### + grammars: [ + "Erlang" + ] + + ### + Supported extensions + ### + extensions: ['erl'] + + options: [] + +} diff --git a/src/languages/index.coffee b/src/languages/index.coffee index 5cbd709..9e174e1 100644 --- a/src/languages/index.coffee +++ b/src/languages/index.coffee @@ -22,6 +22,7 @@ module.exports = class Languages "d" "ejs" "erb" + "erlang" "gherkin" "go" "fortran" From 2977867bbed1728f1aa8d84131d7dd893dba20e3 Mon Sep 17 00:00:00 2001 From: Mark Baas Date: Wed, 25 Nov 2015 17:41:09 -0400 Subject: [PATCH 2/2] updated link --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 90a14ad..302243d 100644 --- a/README.md +++ b/README.md @@ -70,7 +70,7 @@ Or Settings/Preferences ➔ Packages ➔ Search for `atom-beautify` - [x] [TypeScript](https://github.com/Glavin001/atom-beautify/issues/49) - [x] [Haskell](https://github.com/Glavin001/atom-beautify/issues/628) - Requires [stylish-haskell](https://github.com/jaspervdj/stylish-haskell) -- [x] [Erlang]() +- [x] [Erlang](https://github.com/Glavin001/atom-beautify/pull/683) - Requires erlang syntax_tools to be installed ## Usage