Merge pull request #2207 from utkarshkukreti/ocamlformat

Add `ocamlformat` formatter for OCaml.
This commit is contained in:
Steven Zeck 2018-09-11 20:03:39 -05:00 committed by GitHub
commit 80280bb70c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 87 additions and 11 deletions

View File

@ -120,6 +120,7 @@ Some of the supported beautifiers are developed for Node.js and are automaticall
| Lua beautifier | :white_check_mark: | :ok_hand: Not necessary | :smiley: Nothing! | | Lua beautifier | :white_check_mark: | :ok_hand: Not necessary | :smiley: Nothing! |
| Marko Beautifier | :white_check_mark: | :ok_hand: Not necessary | :smiley: Nothing! | | Marko Beautifier | :white_check_mark: | :ok_hand: Not necessary | :smiley: Nothing! |
| Nginx Beautify | :white_check_mark: | :ok_hand: Not necessary | :smiley: Nothing! | | Nginx Beautify | :white_check_mark: | :ok_hand: Not necessary | :smiley: Nothing! |
| ocamlformat | :warning: 1 executable | :x: No Docker support | :bookmark_tabs: Manually:<br/>1. Install [ocamlformat (`ocamlformat`)](https://github.com/ocaml-ppx/ocamlformat) by following https://github.com/ocaml-ppx/ocamlformat#installation<br/> |
| ocp-indent | :warning: 1 executable | :white_check_mark: :100:% of executables | :whale: With [Docker](https://www.docker.com/):<br/>1. Install [ocp-indent (`ocp-indent`)](https://www.typerex.org/ocp-indent.html) with `docker pull unibeautify/ocp-indent`<br/><br/>:bookmark_tabs: Manually:<br/>1. Install [ocp-indent (`ocp-indent`)](https://www.typerex.org/ocp-indent.html) by following https://www.typerex.org/ocp-indent.html#installation<br/> | | ocp-indent | :warning: 1 executable | :white_check_mark: :100:% of executables | :whale: With [Docker](https://www.docker.com/):<br/>1. Install [ocp-indent (`ocp-indent`)](https://www.typerex.org/ocp-indent.html) with `docker pull unibeautify/ocp-indent`<br/><br/>:bookmark_tabs: Manually:<br/>1. Install [ocp-indent (`ocp-indent`)](https://www.typerex.org/ocp-indent.html) by following https://www.typerex.org/ocp-indent.html#installation<br/> |
| Perltidy | :warning: Manual installation | :construction: Not an executable | :page_facing_up: Go to http://perltidy.sourceforge.net/ and follow the instructions. | | Perltidy | :warning: Manual installation | :construction: Not an executable | :page_facing_up: Go to http://perltidy.sourceforge.net/ and follow the instructions. |
| PHP-CS-Fixer | :warning: 2 executables | :warning: Only 1 of 2 executables | :whale: With [Docker](https://www.docker.com/):<br/>1. Install [PHP-CS-Fixer (`php-cs-fixer`)](https://github.com/FriendsOfPHP/PHP-CS-Fixer) with `docker pull unibeautify/php-cs-fixer`<br/><br/>:bookmark_tabs: Manually:<br/>1. Install [PHP (`php`)](http://php.net/) by following http://php.net/manual/en/install.php<br/>2. Install [PHP-CS-Fixer (`php-cs-fixer`)](https://github.com/FriendsOfPHP/PHP-CS-Fixer) by following https://github.com/FriendsOfPHP/PHP-CS-Fixer#installation<br/> | | PHP-CS-Fixer | :warning: 2 executables | :warning: Only 1 of 2 executables | :whale: With [Docker](https://www.docker.com/):<br/>1. Install [PHP-CS-Fixer (`php-cs-fixer`)](https://github.com/FriendsOfPHP/PHP-CS-Fixer) with `docker pull unibeautify/php-cs-fixer`<br/><br/>:bookmark_tabs: Manually:<br/>1. Install [PHP (`php`)](http://php.net/) by following http://php.net/manual/en/install.php<br/>2. Install [PHP-CS-Fixer (`php-cs-fixer`)](https://github.com/FriendsOfPHP/PHP-CS-Fixer) by following https://github.com/FriendsOfPHP/PHP-CS-Fixer#installation<br/> |
@ -191,7 +192,7 @@ See [all supported options in the documentation at `docs/options.md`](docs/opti
| Nginx | `nginx` |`.conf` | **[`Nginx Beautify`](https://github.com/denysvitali/nginxbeautify)** | | Nginx | `nginx` |`.conf` | **[`Nginx Beautify`](https://github.com/denysvitali/nginxbeautify)** |
| Nunjucks | `Nunjucks`, `Nunjucks Templates`, `HTML (Nunjucks Templates)` |`.njk`, `.nunjucks` | **[`Pretty Diff`](https://github.com/prettydiff/prettydiff)** | | Nunjucks | `Nunjucks`, `Nunjucks Templates`, `HTML (Nunjucks Templates)` |`.njk`, `.nunjucks` | **[`Pretty Diff`](https://github.com/prettydiff/prettydiff)** |
| Objective-C | `Objective-C`, `Objective-C++` |`.m`, `.mm`, `.h` | **[`Uncrustify`](https://github.com/uncrustify/uncrustify)**, [`clang-format`](https://clang.llvm.org/docs/ClangFormat.html) | | Objective-C | `Objective-C`, `Objective-C++` |`.m`, `.mm`, `.h` | **[`Uncrustify`](https://github.com/uncrustify/uncrustify)**, [`clang-format`](https://clang.llvm.org/docs/ClangFormat.html) |
| OCaml | `OCaml` |`.ml` | **[`ocp-indent`](https://www.typerex.org/ocp-indent.html)** | | OCaml | `OCaml` |`.ml` | **[`ocp-indent`](https://www.typerex.org/ocp-indent.html)**, [`ocamlformat`](https://github.com/ocaml-ppx/ocamlformat) |
| Pawn | `Pawn` | | **[`Uncrustify`](https://github.com/uncrustify/uncrustify)** | | Pawn | `Pawn` | | **[`Uncrustify`](https://github.com/uncrustify/uncrustify)** |
| Perl | `Perl`, `Perl 6` |`.pl`, `.PL`, `.pm`, `.pod`, `.t` | **[`Perltidy`](http://perltidy.sourceforge.net/)** | | Perl | `Perl`, `Perl 6` |`.pl`, `.PL`, `.pm`, `.pod`, `.t` | **[`Perltidy`](http://perltidy.sourceforge.net/)** |
| PHP | `PHP` |`.php`, `.module`, `.inc` | **[`PHP-CS-Fixer`](https://github.com/FriendsOfPHP/PHP-CS-Fixer)**, [`PHPCBF`](http://php.net/manual/en/install.php), [`hh_format`](http://hhvm.com/) | | PHP | `PHP` |`.php`, `.module`, `.inc` | **[`PHP-CS-Fixer`](https://github.com/FriendsOfPHP/PHP-CS-Fixer)**, [`PHPCBF`](http://php.net/manual/en/install.php), [`hh_format`](http://hhvm.com/) |

View File

@ -300,6 +300,23 @@ Options for isort executable.
2. Go into *Packages* and search for "*Atom Beautify*" package. 2. Go into *Packages* and search for "*Atom Beautify*" package.
3. Find the option "*isort*" and change it to your desired configuration. 3. Find the option "*isort*" and change it to your desired configuration.
##### [ocamlformat](#ocamlformat)
**Important**: This option is only configurable from within Atom Beautify's setting panel.
**Type**: `object`
**Description**:
Options for ocamlformat executable.
**How to Configure**
1. You can open the [Settings View](https://github.com/atom/settings-view) by navigating to
*Edit > Preferences (Linux)*, *Atom > Preferences (OS X)*, or *File > Preferences (Windows)*.
2. Go into *Packages* and search for "*Atom Beautify*" package.
3. Find the option "*ocamlformat*" and change it to your desired configuration.
##### [ocp-indent](#ocp-indent) ##### [ocp-indent](#ocp-indent)
**Important**: This option is only configurable from within Atom Beautify's setting panel. **Important**: This option is only configurable from within Atom Beautify's setting panel.
@ -10268,13 +10285,13 @@ Path to uncrustify config file. i.e. uncrustify.cfg (Supported by Uncrustify)
#### [OCaml](#ocaml) #### [OCaml](#ocaml)
**Supported Beautifiers**: [`ocp-indent`](#ocp-indent) **Supported Beautifiers**: [`ocp-indent`](#ocp-indent) [`ocamlformat`](#ocamlformat)
| Option | ocp-indent | | Option | ocamlformat | ocp-indent |
| --- | --- | | --- | --- | --- |
| `disabled` | :white_check_mark: | | `disabled` | :white_check_mark: | :white_check_mark: |
| `default_beautifier` | :white_check_mark: | | `default_beautifier` | :white_check_mark: | :white_check_mark: |
| `beautify_on_save` | :white_check_mark: | | `beautify_on_save` | :white_check_mark: | :white_check_mark: |
**Description**: **Description**:
@ -10305,7 +10322,7 @@ Disable OCaml Beautification
**Type**: `string` **Type**: `string`
**Enum**: `ocp-indent` **Enum**: `ocp-indent` `ocamlformat`
**Description**: **Description**:

View File

@ -449,7 +449,8 @@
"vhdl", "vhdl",
"vhdl beautifier", "vhdl beautifier",
"gn", "gn",
"blade" "blade",
"ocamlformat"
], ],
"devDependencies": { "devDependencies": {
"codo": "^2.1.2", "codo": "^2.1.2",

View File

@ -87,6 +87,7 @@ module.exports = class Beautifiers extends EventEmitter
'beautysh' 'beautysh'
'terraformfmt' 'terraformfmt'
'verilog-mode' 'verilog-mode'
'ocamlformat'
] ]
### ###

View File

@ -0,0 +1,38 @@
###
Requires https://github.com/ocaml-ppx/ocamlformat
###
"use strict"
Beautifier = require('./beautifier')
module.exports = class OCamlFormat extends Beautifier
name: "ocamlformat"
link: "https://github.com/ocaml-ppx/ocamlformat"
executables: [
{
name: "ocamlformat"
cmd: "ocamlformat"
homepage: "https://github.com/ocaml-ppx/ocamlformat"
installation: "https://github.com/ocaml-ppx/ocamlformat#installation"
version: {
parse: (text) ->
try
text.match(/(\d+\.\d+\.\d+)/)[1]
catch
text.match(/(\d+\.\d+)/)[1] + ".0"
}
}
]
options: {
OCaml: true
}
beautify: (text, language, options) ->
@run("ocamlformat", [
@tempFile("input", text)
], {
help: {
link: "https://github.com/ocaml-ppx/ocamlformat"
}
})

View File

@ -6056,7 +6056,8 @@
"description": "Options for language OCaml", "description": "Options for language OCaml",
"collapsed": true, "collapsed": true,
"beautifiers": [ "beautifiers": [
"ocp-indent" "ocp-indent",
"ocamlformat"
], ],
"grammars": [ "grammars": [
"OCaml" "OCaml"
@ -6079,7 +6080,8 @@
"default": "ocp-indent", "default": "ocp-indent",
"description": "Default Beautifier to be used for OCaml", "description": "Default Beautifier to be used for OCaml",
"enum": [ "enum": [
"ocp-indent" "ocp-indent",
"ocamlformat"
] ]
}, },
"beautify_on_save": { "beautify_on_save": {
@ -9919,6 +9921,22 @@
"description": "Absolute path to the \"terraform\" executable's binary/script." "description": "Absolute path to the \"terraform\" executable's binary/script."
} }
} }
},
"ocamlformat": {
"key": "ocamlformat",
"title": "ocamlformat",
"type": "object",
"collapsed": true,
"description": "Options for ocamlformat executable.",
"properties": {
"path": {
"key": "path",
"title": "Binary/Script Path",
"type": "string",
"default": "",
"description": "Absolute path to the \"ocamlformat\" executable's binary/script."
}
}
} }
} }
} }