diff --git a/CHANGELOG.md b/CHANGELOG.md index a18faf0..b6b21ba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,8 @@ # Next +- Add hindent and brittany beautifiers for haskell - Breaking change to `pybeautifier`: Fix typo, change `formater` to `formatter`. See [#1898](https://github.com/Glavin001/atom-beautify/pull/1898). - Fixes [#1773](https://github.com/Glavin001/atom-beautify/issues/1773) and [#793](https://github.com/Glavin001/atom-beautify/issues/793). ruby-beautify with Rubocop now respects `Exclude` settings, and properly loads inherited config files (like `~/.rubocop.yml`) +- Add hindent and brittany beautifiers for haskell - Fix [#1862](https://github.com/Glavin001/atom-beautify/issues/1862) Add support for ocp-indent as an executable - See [#601](https://github.com/Glavin001/atom-beautify/issues/1862) Add support for tsx files - See [#1497](https://github.com/Glavin001/atom-beautify/issues/1497) and [#802](https://github.com/Glavin001/atom-beautify/issues/802) diff --git a/README.md b/README.md index afb263b..61431e9 100644 --- a/README.md +++ b/README.md @@ -91,6 +91,7 @@ Some of the supported beautifiers are developed for Node.js and are automaticall | align-yaml | :white_check_mark: | :ok_hand: Not necessary | :smiley: Nothing! | | autopep8 | :warning: 2 executables | :warning: Only 1 of 2 executables | :whale: With [Docker](https://www.docker.com/):
1. Install [autopep8 (`autopep8`)](https://github.com/hhatto/autopep8) with `docker pull unibeautify/autopep8`

:bookmark_tabs: Manually:
1. Install [autopep8 (`autopep8`)](https://github.com/hhatto/autopep8) by following https://github.com/hhatto/autopep8#installation
2. Install [isort (`isort`)](https://github.com/timothycrosley/isort) by following https://github.com/timothycrosley/isort#installing-isort
| | beautysh | :warning: 1 executable | :white_check_mark: :100:% of executables | :whale: With [Docker](https://www.docker.com/):
1. Install [beautysh (`beautysh`)](https://github.com/bemeurer/beautysh) with `docker pull unibeautify/beautysh`

:bookmark_tabs: Manually:
1. Install [beautysh (`beautysh`)](https://github.com/bemeurer/beautysh) by following https://github.com/bemeurer/beautysh#installation
| +| brittany | :warning: Manual installation | :construction: Not an executable | :page_facing_up: Go to https://github.com/lspitzner/brittany and follow the instructions. | | clang-format | :warning: 1 executable | :white_check_mark: :100:% of executables | :whale: With [Docker](https://www.docker.com/):
1. Install [ClangFormat (`clang-format`)](https://clang.llvm.org/docs/ClangFormat.html) with `docker pull unibeautify/clang-format`

:bookmark_tabs: Manually:
1. Install [ClangFormat (`clang-format`)](https://clang.llvm.org/docs/ClangFormat.html) by following https://clang.llvm.org/docs/ClangFormat.html
| | cljfmt | :white_check_mark: | :ok_hand: Not necessary | :smiley: Nothing! | | Coffee Formatter | :white_check_mark: | :ok_hand: Not necessary | :smiley: Nothing! | @@ -107,6 +108,7 @@ Some of the supported beautifiers are developed for Node.js and are automaticall | gofmt | :warning: Manual installation | :construction: Not an executable | :page_facing_up: Go to https://golang.org/cmd/gofmt/ and follow the instructions. | | goimports | :warning: 1 executable | :white_check_mark: :100:% of executables | :whale: With [Docker](https://www.docker.com/):
1. Install [goimports (`goimports`)](https://godoc.org/golang.org/x/tools/cmd/goimports) with `docker pull unibeautify/goimports`

:bookmark_tabs: Manually:
1. Install [goimports (`goimports`)](https://godoc.org/golang.org/x/tools/cmd/goimports) by following https://godoc.org/golang.org/x/tools/cmd/goimports
| | hh_format | :warning: Manual installation | :construction: Not an executable | :page_facing_up: Go to http://hhvm.com/ and follow the instructions. | +| hindent | :warning: Manual installation | :construction: Not an executable | :page_facing_up: Go to https://github.com/commercialhaskell/hindent and follow the instructions. | | HTML Beautifier | :warning: Manual installation | :construction: Not an executable | :page_facing_up: Go to https://github.com/threedaymonk/htmlbeautifier and follow the instructions. | | JS Beautify | :white_check_mark: | :ok_hand: Not necessary | :smiley: Nothing! | | JSCS Fixer | :white_check_mark: | :ok_hand: Not necessary | :smiley: Nothing! | @@ -166,7 +168,7 @@ See [all supported options in the documentation at `docs/options.md`](docs/opti | Go | `Go` |`.go` | **[`gofmt`](https://golang.org/cmd/gofmt/)**, [`goimports`](https://godoc.org/golang.org/x/tools/cmd/goimports) | | Golang Template | `HTML (Go)`, `Go Template` |`.gohtml` | **[`Pretty Diff`](https://github.com/prettydiff/prettydiff)** | | Handlebars | `Handlebars`, `HTML (Handlebars)` |`.hbs`, `.handlebars` | **[`JS Beautify`](https://github.com/beautify-web/js-beautify)**, [`Pretty Diff`](https://github.com/prettydiff/prettydiff) | -| Haskell | `Haskell` |`.hs` | **[`stylish-haskell`](https://github.com/jaspervdj/stylish-haskell)** | +| Haskell | `Haskell` |`.hs` | **[`brittany`](https://github.com/lspitzner/brittany)**, [`hindent`](https://github.com/commercialhaskell/hindent), [`stylish-haskell`](https://github.com/jaspervdj/stylish-haskell) | | HTML | `HTML` |`.html` | **[`JS Beautify`](https://github.com/beautify-web/js-beautify)**, [`Pretty Diff`](https://github.com/prettydiff/prettydiff) | | Jade | `Jade`, `Pug` |`.jade`, `.pug` | **[`Pug Beautify`](https://github.com/vingorius/pug-beautify)** | | Java | `Java` |`.java` | **[`Uncrustify`](https://github.com/uncrustify/uncrustify)** | diff --git a/docs/code/alphabetical_index.html b/docs/code/alphabetical_index.html index bee2772..3fb9fa7 100644 --- a/docs/code/alphabetical_index.html +++ b/docs/code/alphabetical_index.html @@ -60,6 +60,11 @@ Beautifiers +
  • + + Brittany + +
  • - \ No newline at end of file + diff --git a/docs/code/class/Beautifiers.html b/docs/code/class/Beautifiers.html index 8d4fc39..4ab3fd7 100644 --- a/docs/code/class/Beautifiers.html +++ b/docs/code/class/Beautifiers.html @@ -46,7 +46,7 @@ =
    -
    ['uncrustify', 'autopep8', 'coffee-formatter', 'coffee-fmt', 'cljfmt', 'clang-format', 'crystal', 'dfmt', 'elm-format', 'htmlbeautifier', 'csscomb', 'gherkin', 'gofmt', 'latex-beautify', 'fortran-beautifier', 'js-beautify', 'jscs', 'lua-beautifier', 'ocp-indent', 'perltidy', 'php-cs-fixer', 'phpcbf', 'prettydiff', 'pug-beautify', 'puppet-fix', 'remark', 'rubocop', 'ruby-beautify', 'rustfmt', 'sass-convert', 'sqlformat', 'stylish-haskell', 'tidy-markdown', 'typescript-formatter', 'vue-beautifier', 'yapf', 'erl_tidy', 'marko-beautifier', 'formatR', 'beautysh']
    +
    ['uncrustify', 'autopep8', 'brittany', 'coffee-formatter', 'coffee-fmt', 'cljfmt', 'clang-format', 'crystal', 'dfmt', 'elm-format', 'htmlbeautifier', 'csscomb', 'gherkin', 'gofmt', 'latex-beautify', 'fortran-beautifier', 'hindent', 'js-beautify', 'jscs', 'lua-beautifier', 'ocp-indent', 'perltidy', 'php-cs-fixer', 'phpcbf', 'prettydiff', 'pug-beautify', 'puppet-fix', 'remark', 'rubocop', 'ruby-beautify', 'rustfmt', 'sass-convert', 'sqlformat', 'stylish-haskell', 'tidy-markdown', 'typescript-formatter', 'vue-beautifier', 'yapf', 'erl_tidy', 'marko-beautifier', 'formatR', 'beautysh']

    List of beautifier names

    To register a beautifier add its name here

    @@ -83,7 +83,7 @@
    {}
    - +

    Instance Method Summary

    @@ -97,7 +97,7 @@ - From https://github.com/atom/notifications/blob/01779ade79e7196f1603b8c1fa31716aa4a33911/lib/notification-issue.coffee#L130 + From https://github.com/atom/notifications/blob/01779ade79e7196f1603b8c1fa31716aa4a33911/lib/notification-issue.coffee#L130
  • @@ -208,7 +208,7 @@ - CLI + CLI
  • @@ -269,7 +269,7 @@ lookups when liniting an entire project - Look for .jsbeautifierrc in file and home path, check env variables + Look for .jsbeautifierrc in file and home path, check env variables
  • @@ -345,7 +345,7 @@ lookups when liniting an entire project getBeautifiers(language)

    - +

    @@ -354,7 +354,7 @@ lookups when liniting an entire project getBeautifierForLanguage(language)

    - +

    @@ -363,7 +363,7 @@ lookups when liniting an entire project getLanguage(grammar, filePath)

    - +

    @@ -372,7 +372,7 @@ lookups when liniting an entire project getOptionsForLanguage(allOptions, language)

    - +

    @@ -381,7 +381,7 @@ lookups when liniting an entire project transformOptions(beautifier, languageName, options)

    - +

    @@ -390,7 +390,7 @@ lookups when liniting an entire project trackEvent(payload)

    - +

    @@ -399,7 +399,7 @@ lookups when liniting an entire project trackTiming(payload)

    - +

    @@ -408,7 +408,7 @@ lookups when liniting an entire project track(type, payload)

    - +

    @@ -417,7 +417,7 @@ lookups when liniting an entire project beautify(text, allOptions, grammar, filePath, {onSave} = {})

    - +

    @@ -439,7 +439,7 @@ lookups when liniting an entire project verifyExists(fullPath)

    - +

    @@ -511,7 +511,7 @@ or in the home directory. Configuration files are named getConfigOptionsFromSettings(langs)

    - +

    @@ -533,7 +533,7 @@ or in the home directory. Configuration files are named getOptionsForPath(editedFilePath, editor)

    - +

    @@ -542,7 +542,7 @@ or in the home directory. Configuration files are named isNestedOptions(currOptions)

    - +

    @@ -552,7 +552,7 @@ or in the home directory. Configuration files are named Bound

    - +
    @@ -628,4 +628,4 @@ or in the home directory. Configuration files are named - \ No newline at end of file + diff --git a/docs/code/class/Brittany.html b/docs/code/class/Brittany.html new file mode 100644 index 0000000..95b2bac --- /dev/null +++ b/docs/code/class/Brittany.html @@ -0,0 +1,204 @@ + + + + + Atom-Beautify Documentation + + + + + +
    + +
    +

    + Class: + Brittany +

    + + + + + + + + + +
    Defined in:src/beautifiers/brittany.coffee
    Inherits: + Beautifier +
    +

    Variables Summary

    +
    +
    + name + = +
    +
    +
    "brittany"
    + +
    + +
    +
    "https://github.com/lspitzner/brittany"
    + +
    +
    + options + = +
    +
    +
    {
    +  Haskell: true
    +}
    + +
    +
    +

    + Variable inherited from + Beautifier +

    +

    + Promise + name + options + languages + beautify + _envCache + _envCacheDate + _envCacheExpiry + logger +

    +

    Instance Method Summary

    + +

    + Inherited Method Summary +

    + Methods inherited from + Beautifier +

    +

    + #deprecate + #tempFile + #readFile + #findFile + #getShellEnvironment + #which + #commandNotFoundError + #run + #spawn + #setupLogger +

    + +

    Instance Method Details

    +
    +
    +

    + # +(void) +beautify(text, language, options) +
    +

    + +
    +
    +
    + + +
    + +
      +
      +
      +

      + Quickly fuzzy find classes, mixins, methods, file: +

      + +

      + Control the navigation frame: +

      + +

      + You can focus and blur the search input: +

      + +
      + + diff --git a/docs/code/class/Hindent.html b/docs/code/class/Hindent.html new file mode 100644 index 0000000..23767f2 --- /dev/null +++ b/docs/code/class/Hindent.html @@ -0,0 +1,204 @@ + + + + + Atom-Beautify Documentation + + + + + +
      + +
      +

      + Class: + Hindent +

      + + + + + + + + + +
      Defined in:src/beautifiers/hindent.coffee
      Inherits: + Beautifier +
      +

      Variables Summary

      +
      +
      + name + = +
      +
      +
      "hindent"
      + +
      + +
      +
      "https://github.com/commercialhaskell/hindent"
      + +
      +
      + options + = +
      +
      +
      {
      +  Haskell: true
      +}
      + +
      +
      +

      + Variable inherited from + Beautifier +

      +

      + Promise + name + options + languages + beautify + _envCache + _envCacheDate + _envCacheExpiry + logger +

      +

      Instance Method Summary

      + +

      + Inherited Method Summary +

      + Methods inherited from + Beautifier +

      +

      + #deprecate + #tempFile + #readFile + #findFile + #getShellEnvironment + #which + #commandNotFoundError + #run + #spawn + #setupLogger +

      + +

      Instance Method Details

      +
      +
      +

      + # +(void) +beautify(text, language, options) +
      +

      + +
      +
      +
      + + +
      + +
        +
        +
        +

        + Quickly fuzzy find classes, mixins, methods, file: +

        + +

        + Control the navigation frame: +

        + +

        + You can focus and blur the search input: +

        + +
        + + diff --git a/docs/code/file/src/beautifiers/brittany.coffee.html b/docs/code/file/src/beautifiers/brittany.coffee.html new file mode 100644 index 0000000..759b6c3 --- /dev/null +++ b/docs/code/file/src/beautifiers/brittany.coffee.html @@ -0,0 +1,123 @@ + + + + + Atom-Beautify Documentation + + + + + +
        + +
        +

        + File: + brittany.coffee +

        + + + + + + + + + +
        Defined in:src/beautifiers
        + Classes: + + + StylishHaskell + +
        +
        + + +
        + +
          +
          +
          +

          + Quickly fuzzy find classes, mixins, methods, file: +

          + +

          + Control the navigation frame: +

          + +

          + You can focus and blur the search input: +

          + +
          + + diff --git a/docs/code/file/src/beautifiers/hindent.coffee.html b/docs/code/file/src/beautifiers/hindent.coffee.html new file mode 100644 index 0000000..2a23412 --- /dev/null +++ b/docs/code/file/src/beautifiers/hindent.coffee.html @@ -0,0 +1,123 @@ + + + + + Atom-Beautify Documentation + + + + + +
          + +
          +

          + File: + hindent.coffee +

          + + + + + + + + + +
          Defined in:src/beautifiers
          + Classes: + + + StylishHaskell + +
          +
          + + +
          + +
            +
            +
            +

            + Quickly fuzzy find classes, mixins, methods, file: +

            + +

            + Control the navigation frame: +

            + +

            + You can focus and blur the search input: +

            + +
            + + diff --git a/docs/code/file_list.html b/docs/code/file_list.html index 2ce9f23..4481c80 100644 --- a/docs/code/file_list.html +++ b/docs/code/file_list.html @@ -65,6 +65,14 @@ src/beautifiers
          1. +
          2. + + brittany.coffee + + + src/beautifiers + +
          3. clang-format.coffee @@ -88,7 +96,7 @@
          4. - +
          5. coffee-fmt.coffee @@ -160,7 +168,7 @@
          6. - +
          7. fortran-beautifier @@ -176,7 +184,7 @@
          8. - +
          9. gherkin.coffee @@ -193,6 +201,14 @@ src/beautifiers
          10. +
          11. + + hindent.coffee + + + src/beautifiers + +
          12. htmlbeautifier.coffee @@ -248,7 +264,7 @@
          13. - +
          14. marko-beautifier.coffee @@ -408,7 +424,7 @@
          15. - +
          16. vue-beautifier.coffee @@ -426,7 +442,7 @@
          17. - +
          18. beautify.coffee @@ -946,7 +962,7 @@
          19. - +
          20. views @@ -970,11 +986,11 @@
          21. - + - + - + - \ No newline at end of file + diff --git a/docs/options.md b/docs/options.md index 322ffd0..c46cbe7 100644 --- a/docs/options.md +++ b/docs/options.md @@ -4315,13 +4315,13 @@ Maximum characters per line (0 disables) (Supported by JS Beautify, Pretty Diff) #### [Haskell](#haskell) -**Supported Beautifiers**: [`stylish-haskell`](#stylish-haskell) +**Supported Beautifiers**: [`brittany`](#brittany) [`hindent`](#hindent) [`stylish-haskell`](#stylish-haskell) -| Option | stylish-haskell | -| --- | --- | -| `disabled` | :white_check_mark: | -| `default_beautifier` | :white_check_mark: | -| `beautify_on_save` | :white_check_mark: | +| Option | brittany | hindent | stylish-haskell | +| --- | --- | --- | --- | +| `disabled` | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| `default_beautifier` | :white_check_mark: | :white_check_mark: | :white_check_mark: | +| `beautify_on_save` | :white_check_mark: | :white_check_mark: | :white_check_mark: | **Description**: @@ -4352,7 +4352,7 @@ Disable Haskell Beautification **Type**: `string` -**Enum**: `stylish-haskell` +**Enum**: `brittany` `hindent` `stylish-haskell` **Description**: diff --git a/examples/nested-jsbeautifyrc/haskell/expected/test.hs b/examples/nested-jsbeautifyrc/haskell/expected/test.hs deleted file mode 100644 index 7db6a80..0000000 --- a/examples/nested-jsbeautifyrc/haskell/expected/test.hs +++ /dev/null @@ -1,10 +0,0 @@ -{-# LANGUAGE Wat #-} -import Bar -import Foo - -import qualified Baz as Bang - -data Person = Person { - name :: String, - address :: String -} diff --git a/examples/nested-jsbeautifyrc/haskell/expected/test_brittany.hs b/examples/nested-jsbeautifyrc/haskell/expected/test_brittany.hs new file mode 100644 index 0000000..0a89dd8 --- /dev/null +++ b/examples/nested-jsbeautifyrc/haskell/expected/test_brittany.hs @@ -0,0 +1,33 @@ +{-# LANGUAGE OverloadedStrings #-} +module TypeFun where +import Foo +import Bar +import qualified Baz as Bang +import Data.Typeable + +data Person = Person { + name :: String, + address :: String +} + +main :: IO () +main = do + doSomethingOnType 'c' + doSomethingOnType (35 :: Integer) + doSomethingOnType "a string" + +doSomethingOnType :: Typeable a => a -> IO () +doSomethingOnType a = case show (typeOf a) of + "Char" -> print $ performActionOnChar a + "Integer" -> print $ performActionOnInt a + _ -> print "undefined!" + +performActionOnChar :: Typeable a => a -> String +performActionOnChar a = case cast a :: Maybe Char of + Just c -> "Concatenating with string: " ++ [c] + Nothing -> "Cast went wrong..." + +performActionOnInt :: Typeable a => a -> String +performActionOnInt a = case cast a :: Maybe Integer of + Just i -> "Concatenating with string: " ++ show (i + 10) + Nothing -> "Cast went wrong..." diff --git a/examples/nested-jsbeautifyrc/haskell/expected/test_hindent.hs b/examples/nested-jsbeautifyrc/haskell/expected/test_hindent.hs new file mode 100644 index 0000000..e757c02 --- /dev/null +++ b/examples/nested-jsbeautifyrc/haskell/expected/test_hindent.hs @@ -0,0 +1,38 @@ +{-# LANGUAGE OverloadedStrings #-} + +module TypeFun where + +import Bar +import qualified Baz as Bang +import Data.Typeable +import Foo + +data Person = Person + { name :: String + , address :: String + } + +main :: IO () +main = do + doSomethingOnType 'c' + doSomethingOnType (35 :: Integer) + doSomethingOnType "a string" + +doSomethingOnType :: Typeable a => a -> IO () +doSomethingOnType a = + case show (typeOf a) of + "Char" -> print $ performActionOnChar a + "Integer" -> print $ performActionOnInt a + _ -> print "undefined!" + +performActionOnChar :: Typeable a => a -> String +performActionOnChar a = + case cast a :: Maybe Char of + Just c -> "Concatenating with string: " ++ [c] + Nothing -> "Cast went wrong..." + +performActionOnInt :: Typeable a => a -> String +performActionOnInt a = + case cast a :: Maybe Integer of + Just i -> "Concatenating with string: " ++ show (i + 10) + Nothing -> "Cast went wrong..." diff --git a/examples/nested-jsbeautifyrc/haskell/expected/test_stylishhaskell.hs b/examples/nested-jsbeautifyrc/haskell/expected/test_stylishhaskell.hs new file mode 100644 index 0000000..3f2339f --- /dev/null +++ b/examples/nested-jsbeautifyrc/haskell/expected/test_stylishhaskell.hs @@ -0,0 +1,36 @@ +{-# LANGUAGE OverloadedStrings #-} +module TypeFun where +import Bar +import qualified Baz as Bang +import Data.Typeable +import Foo + +data Person = Person { + name :: String, + address :: String +} + +main :: IO () +main = do + doSomethingOnType 'c' + doSomethingOnType (35 :: Integer) + doSomethingOnType "a string" + +doSomethingOnType :: Typeable a => a -> IO () +doSomethingOnType a = + case show (typeOf a) of + "Char" -> print $ performActionOnChar a + "Integer" -> print $ performActionOnInt a + _ -> print "undefined!" + +performActionOnChar :: Typeable a => a -> String +performActionOnChar a = + case cast a :: Maybe Char of + Just c -> "Concatenating with string: " ++ [c] + Nothing -> "Cast went wrong..." + +performActionOnInt :: Typeable a => a -> String +performActionOnInt a = + case cast a :: Maybe Integer of + Just i -> "Concatenating with string: " ++ show (i + 10) + Nothing -> "Cast went wrong..." diff --git a/examples/nested-jsbeautifyrc/haskell/original/_test.hs b/examples/nested-jsbeautifyrc/haskell/original/_test.hs index 7d9267c..9298c1e 100644 --- a/examples/nested-jsbeautifyrc/haskell/original/_test.hs +++ b/examples/nested-jsbeautifyrc/haskell/original/_test.hs @@ -1,10 +1,36 @@ -{-# LANGUAGE Wat #-} +{-# LANGUAGE OverloadedStrings #-} +module TypeFun where import Foo import Bar - import qualified Baz as Bang +import Data.Typeable data Person = Person { name :: String, address :: String } + +main :: IO () +main = do + doSomethingOnType 'c' + doSomethingOnType (35 :: Integer) + doSomethingOnType "a string" + +doSomethingOnType :: Typeable a => a -> IO () +doSomethingOnType a = + case show (typeOf a) of + "Char" -> print $ performActionOnChar a + "Integer" -> print $ performActionOnInt a + _ -> print "undefined!" + +performActionOnChar :: Typeable a => a -> String +performActionOnChar a = + case cast a :: Maybe Char of + Just c -> "Concatenating with string: " ++ [c] + Nothing -> "Cast went wrong..." + +performActionOnInt :: Typeable a => a -> String +performActionOnInt a = + case cast a :: Maybe Integer of + Just i -> "Concatenating with string: " ++ show (i + 10) + Nothing -> "Cast went wrong..." diff --git a/package.json b/package.json index d0d4d46..d334b2c 100644 --- a/package.json +++ b/package.json @@ -150,6 +150,11 @@ { "name": "Steven Zeck", "url": "https://github.com/szeck87" + }, + { + "name": "Christian Kjær Laustsen", + "email": "ckl@codetalk.io", + "url": "https://github.com/Tehnix" } ], "engines": { @@ -344,6 +349,8 @@ "gherkin", "fortran", "haskell", + "hindent", + "brittany", "jade", "jsx", "latex", diff --git a/src/beautifiers/brittany.coffee b/src/beautifiers/brittany.coffee new file mode 100644 index 0000000..1f4445c --- /dev/null +++ b/src/beautifiers/brittany.coffee @@ -0,0 +1,24 @@ +### +Requires https://github.com/lspitzner/brittany +### + +"use strict" +Beautifier = require('./beautifier') + +module.exports = class Brittany extends Beautifier + name: "brittany" + link: "https://github.com/lspitzner/brittany" + isPreInstalled: false + + options: { + Haskell: true + } + + beautify: (text, language, options) -> + @run("brittany", [ + @tempFile("input", text) + ], { + help: { + link: "https://github.com/lspitzner/brittany" + } + }) diff --git a/src/beautifiers/hindent.coffee b/src/beautifiers/hindent.coffee new file mode 100644 index 0000000..c1b9756 --- /dev/null +++ b/src/beautifiers/hindent.coffee @@ -0,0 +1,27 @@ +### +Requires https://github.com/commercialhaskell/hindent +### + +"use strict" +Beautifier = require('./beautifier') + +module.exports = class Hindent extends Beautifier + name: "hindent" + link: "https://github.com/commercialhaskell/hindent" + isPreInstalled: false + + options: { + Haskell: true + } + + beautify: (text, language, options) -> + @run("hindent", [ + tempFile = @tempFile("temp", text) + ], { + help: { + link: "https://github.com/commercialhaskell/hindent" + } + }) + .then(=> + @readFile(tempFile) + ) diff --git a/src/beautifiers/index.coffee b/src/beautifiers/index.coffee index 3d57821..54117a1 100644 --- a/src/beautifiers/index.coffee +++ b/src/beautifiers/index.coffee @@ -37,6 +37,7 @@ module.exports = class Beautifiers extends EventEmitter 'uncrustify' 'align-yaml' 'autopep8' + 'brittany' 'coffee-formatter' 'coffee-fmt' 'cljfmt' @@ -52,6 +53,7 @@ module.exports = class Beautifiers extends EventEmitter 'goimports' 'latex-beautify' 'fortran-beautifier' + 'hindent' 'js-beautify' 'jscs' 'eslint' diff --git a/src/languages/haskell.coffee b/src/languages/haskell.coffee index 31ec842..649156d 100644 --- a/src/languages/haskell.coffee +++ b/src/languages/haskell.coffee @@ -17,6 +17,8 @@ module.exports = { "hs" ] + defaultBeautifier: "stylish-haskell" + options: [] } diff --git a/src/options.json b/src/options.json index 5cce5cf..1a8ec7a 100644 --- a/src/options.json +++ b/src/options.json @@ -2395,6 +2395,8 @@ "description": "Options for language Haskell", "collapsed": true, "beautifiers": [ + "brittany", + "hindent", "stylish-haskell" ], "grammars": [ @@ -2415,9 +2417,11 @@ "title": "Default Beautifier", "order": -2, "type": "string", - "default": "stylish-haskell", + "default": "brittany", "description": "Default Beautifier to be used for Haskell", "enum": [ + "brittany", + "hindent", "stylish-haskell" ] },