From 0044fab6255ea90888df9c42b57a3b2b6fdab2ed Mon Sep 17 00:00:00 2001 From: Christian Kjaer Laustsen Date: Sat, 28 Oct 2017 12:41:20 +0200 Subject: [PATCH 1/4] Add hindent and brittany beautifiers for haskell --- CHANGELOG.md | 2 +- docs/code/alphabetical_index.html | 30 ++- docs/code/class/Beautifiers.html | 40 ++-- docs/code/class/Brittany.html | 204 ++++++++++++++++++ docs/code/class/Hindent.html | 204 ++++++++++++++++++ .../file/src/beautifiers/brittany.coffee.html | 123 +++++++++++ .../file/src/beautifiers/hindent.coffee.html | 123 +++++++++++ docs/code/file_list.html | 38 +++- package.json | 9 +- src/beautifiers/brittany.coffee | 24 +++ src/beautifiers/hindent.coffee | 27 +++ src/beautifiers/index.coffee | 2 + src/options.json | 10 +- 13 files changed, 799 insertions(+), 37 deletions(-) create mode 100644 docs/code/class/Brittany.html create mode 100644 docs/code/class/Hindent.html create mode 100644 docs/code/file/src/beautifiers/brittany.coffee.html create mode 100644 docs/code/file/src/beautifiers/hindent.coffee.html create mode 100644 src/beautifiers/brittany.coffee create mode 100644 src/beautifiers/hindent.coffee diff --git a/CHANGELOG.md b/CHANGELOG.md index 171b381..ac1e0a9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,7 @@ # Next - See [#881](https://github.com/Glavin001/atom-beautify/issues/881). Update to Prettydiff version 2! - Fix for [#1888](https://github.com/Glavin001/atom-beautify/issues/1888). Allow 0 for minor and patch versions of Docker -- ... +- Add hindent and brittany beautifiers for haskell # v0.30.5 (2017-08-11) - Fix for [#1721](https://github.com/Glavin001/atom-beautify/issues/1721). Changes required due to TextBuffer.save becoming async in Atom 1.19 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: +

      +
        +
      • + T + Open fuzzy finder dialog +
      • +
      +

      + Control the navigation frame: +

      +
        +
      • + L + Toggle list view +
      • +
      • + C + Show class list +
      • +
      • + I + Show mixin list +
      • +
      • + F + Show file list +
      • +
      • + M + Show method list +
      • +
      • + E + Show extras list +
      • +
      +

      + You can focus and blur the search input: +

      +
        +
      • + S + Focus search input +
      • +
      • + Esc + Blur 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: +

        +
          +
        • + T + Open fuzzy finder dialog +
        • +
        +

        + Control the navigation frame: +

        +
          +
        • + L + Toggle list view +
        • +
        • + C + Show class list +
        • +
        • + I + Show mixin list +
        • +
        • + F + Show file list +
        • +
        • + M + Show method list +
        • +
        • + E + Show extras list +
        • +
        +

        + You can focus and blur the search input: +

        +
          +
        • + S + Focus search input +
        • +
        • + Esc + Blur 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: +

          +
            +
          • + T + Open fuzzy finder dialog +
          • +
          +

          + Control the navigation frame: +

          +
            +
          • + L + Toggle list view +
          • +
          • + C + Show class list +
          • +
          • + I + Show mixin list +
          • +
          • + F + Show file list +
          • +
          • + M + Show method list +
          • +
          • + E + Show extras list +
          • +
          +

          + You can focus and blur the search input: +

          +
            +
          • + S + Focus search input +
          • +
          • + Esc + Blur 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: +

            +
              +
            • + T + Open fuzzy finder dialog +
            • +
            +

            + Control the navigation frame: +

            +
              +
            • + L + Toggle list view +
            • +
            • + C + Show class list +
            • +
            • + I + Show mixin list +
            • +
            • + F + Show file list +
            • +
            • + M + Show method list +
            • +
            • + E + Show extras list +
            • +
            +

            + You can focus and blur the search input: +

            +
              +
            • + S + Focus search input +
            • +
            • + Esc + Blur 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/package.json b/package.json index 17b14a7..c3b9b1d 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": { @@ -340,6 +345,8 @@ "gherkin", "fortran", "haskell", + "hindent", + "brittany", "jade", "jsx", "latex", @@ -445,4 +452,4 @@ "prettydiff2" ] } -} +} \ No newline at end of file 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 b3e630c..816bcf4 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/options.json b/src/options.json index 8767e0d..c39c914 100644 --- a/src/options.json +++ b/src/options.json @@ -2632,7 +2632,9 @@ "description": "Options for language Haskell", "collapsed": true, "beautifiers": [ - "stylish-haskell" + "stylish-haskell", + "hindent", + "brittany" ], "grammars": [ "Haskell" @@ -2655,7 +2657,9 @@ "default": "stylish-haskell", "description": "Default Beautifier to be used for Haskell", "enum": [ - "stylish-haskell" + "stylish-haskell", + "hindent", + "brittany" ] }, "beautify_on_save": { @@ -9377,4 +9381,4 @@ } } } -} \ No newline at end of file +} From 7121eef0be7f255c4454e3ea2a5ec5db767c6794 Mon Sep 17 00:00:00 2001 From: Christian Kjaer Laustsen Date: Sat, 28 Oct 2017 12:53:31 +0200 Subject: [PATCH 2/4] Run docs and add examples --- README.md | 4 +- docs/options.md | 16 ++++---- .../haskell/expected/test.hs | 10 ----- .../haskell/expected/test_brittany.hs | 33 ++++++++++++++++ .../haskell/expected/test_hindent.hs | 38 +++++++++++++++++++ .../haskell/expected/test_stylishhaskell.hs | 36 ++++++++++++++++++ .../haskell/original/_test.hs | 30 ++++++++++++++- src/options.json | 12 +++--- 8 files changed, 152 insertions(+), 27 deletions(-) delete mode 100644 examples/nested-jsbeautifyrc/haskell/expected/test.hs create mode 100644 examples/nested-jsbeautifyrc/haskell/expected/test_brittany.hs create mode 100644 examples/nested-jsbeautifyrc/haskell/expected/test_hindent.hs create mode 100644 examples/nested-jsbeautifyrc/haskell/expected/test_stylishhaskell.hs diff --git a/README.md b/README.md index c33233e..5b80850 100644 --- a/README.md +++ b/README.md @@ -73,6 +73,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! | @@ -89,6 +90,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! | @@ -146,7 +148,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/options.md b/docs/options.md index 19e54ff..1532ad5 100644 --- a/docs/options.md +++ b/docs/options.md @@ -4678,13 +4678,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**: @@ -4711,11 +4711,11 @@ Disable Haskell Beautification **Important**: This option is only configurable from within Atom Beautify's setting panel. -**Default**: `stylish-haskell` +**Default**: `brittany` **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/src/options.json b/src/options.json index c39c914..28d587d 100644 --- a/src/options.json +++ b/src/options.json @@ -2632,9 +2632,9 @@ "description": "Options for language Haskell", "collapsed": true, "beautifiers": [ - "stylish-haskell", + "brittany", "hindent", - "brittany" + "stylish-haskell" ], "grammars": [ "Haskell" @@ -2654,12 +2654,12 @@ "title": "Default Beautifier", "order": -2, "type": "string", - "default": "stylish-haskell", + "default": "brittany", "description": "Default Beautifier to be used for Haskell", "enum": [ - "stylish-haskell", + "brittany", "hindent", - "brittany" + "stylish-haskell" ] }, "beautify_on_save": { @@ -9381,4 +9381,4 @@ } } } -} +} \ No newline at end of file From d122715840e9d410289df5365497886cbf3708ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Kj=C3=A6r?= Date: Wed, 8 Nov 2017 09:12:25 +0900 Subject: [PATCH 3/4] Move changelog entry to "next" section --- CHANGELOG.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5a0318d..c97538e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,5 @@ # Next -- ... +- Add hindent and brittany beautifiers for haskell # v0.30.6 (2017-10-30) - See [#645](https://github.com/Glavin001/atom-beautify/issues/645). Add support for Terraform fmt. @@ -9,7 +9,6 @@ - Add `.ttslua` file extension to Lua language - Fix [#1638]. Update TypeScript Formatter dependency - Fix [#1833] `os.tmpDir` deprecation warning -- Add hindent and brittany beautifiers for haskell # v0.30.5 (2017-08-11) - Fix for [#1721](https://github.com/Glavin001/atom-beautify/issues/1721). Changes required due to TextBuffer.save becoming async in Atom 1.19 From 335f7594e75f1c105eff7d1f938c3d3a60e00703 Mon Sep 17 00:00:00 2001 From: Christian Kjaer Laustsen Date: Mon, 26 Feb 2018 19:12:30 +0100 Subject: [PATCH 4/4] Set stylish-haskell as the default haskell beautifier --- src/languages/haskell.coffee | 2 ++ 1 file changed, 2 insertions(+) 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: [] }