Merge pull request #700 from splodingsocks/master

Add support for Elm
This commit is contained in:
Glavin Wiechert 2015-12-11 00:33:06 -04:00
commit 29a0461467
13 changed files with 130 additions and 4 deletions

View File

@ -59,3 +59,6 @@ before_install:
- brew install haskell-stack
- stack setup
- stack install stylish-haskell
# Elm
- curl -L -o /tmp/elm-format.tgz https://github.com/avh4/elm-format/releases/download/0.1-alpha2/elm-format-0.1-alpha2-mac-x64.tgz
- tar xvzf /tmp/elm-format.tgz -C /usr/local/bin

View File

@ -1,4 +1,5 @@
# dev
- Add [elm-format](https://github.com/avh4/elm-format) beautifier for the Elm language.
- Add [clang-format](http://clang.llvm.org/docs/ClangFormat.html) beautifier for C/C++/Obj-C languages.
- Add [yapf](http://github.com/google/yapf) beautifier for Python.

View File

@ -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] [Elm](https://github.com/Glavin001/atom-beautify/pull/700)
- Requires [Elm-Format](https://github.com/avh4/elm-format)
## Usage

View File

@ -115,7 +115,7 @@ build_script:
- cd %APPVEYOR_BUILD_FOLDER%
# Install languages to Atom
- apm install language-marko language-html-swig language-svg
- apm install language-marko language-html-swig language-svg language-elm
# Show current PATH
- echo %PATH%
# Run tests on package

View File

@ -2467,6 +2467,61 @@ Automatically beautify EJS files on save
2. Go into *Packages* and search for "*Atom Beautify*" package.
3. Find the option "*Language Config - EJS - Beautify On Save*" and change it to your desired configuration.
#### [Language Config - Elm - Disable Beautifying Language](#language-config---elm---disable-beautifying-language)
**Important**: This option is only configurable from within Atom Beautify's setting panel.
**Type**: `boolean`
**Description**:
Disable Elm Beautification
**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 "*Language Config - Elm - Disable Beautifying Language*" and change it to your desired configuration.
#### [Language Config - Elm - Default Beautifier](#language-config---elm---default-beautifier)
**Important**: This option is only configurable from within Atom Beautify's setting panel.
**Default**: `elm-format`
**Type**: `string`
**Enum**: `elm-format`
**Description**:
Default Beautifier to be used for Elm
**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 "*Language Config - Elm - Default Beautifier*" and change it to your desired configuration.
#### [Language Config - Elm - Beautify On Save](#language-config---elm---beautify-on-save)
**Important**: This option is only configurable from within Atom Beautify's setting panel.
**Type**: `boolean`
**Description**:
Automatically beautify Elm files on save
**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 "*Language Config - Elm - Beautify On Save*" and change it to your desired configuration.
#### [Language Config - ERB - Disable Beautifying Language](#language-config---erb---disable-beautifying-language)
**Important**: This option is only configurable from within Atom Beautify's setting panel.

View File

@ -0,0 +1,9 @@
module Main (..) where
addThings x y =
x + y
main =
addThings 4 5

View File

@ -0,0 +1,3 @@
addThings x y = x + y
main = addThings 4 5

View File

@ -58,6 +58,10 @@
{
"name": "Daniel Bayley",
"url": "https://github.com/danielbayley"
},
{
"name": "Murphy Randle",
"url": "https://github.com/splodingsocks"
}
],
"engines": {
@ -156,7 +160,8 @@
"marko",
"go",
"golang",
"svg"
"svg",
"elm"
],
"devDependencies": {
"coffee-script": "^1.9.3",

View File

@ -54,10 +54,10 @@ module.exports = class Beautifier
###
Create temporary file
###
tempFile: (name = "atom-beautify-temp", contents = "") ->
tempFile: (name = "atom-beautify-temp", contents = "", ext = "") ->
return new Promise((resolve, reject) =>
# create temp file
temp.open(name, (err, info) =>
temp.open({prefix: name, suffix: ext}, (err, info) =>
@debug('tempFile', name, err, info)
return reject(err) if err
fs.write(info.fd, contents, (err) ->

View File

@ -0,0 +1,24 @@
###
Requires https://github.com/avh4/elm-format
###
"use strict"
Beautifier = require('./beautifier')
module.exports = class ElmFormat extends Beautifier
name: "elm-format"
options: {
Elm: true
}
beautify: (text, language, options) ->
tempfile = @tempFile("input", text, ".elm")
.then (name) =>
@run("elm-format", [
'--yes',
name
],
{ help: { link: 'https://github.com/avh4/elm-format' } }
)
.then () =>
@readFile(name)

View File

@ -38,6 +38,7 @@ module.exports = class Beautifiers extends EventEmitter
'coffee-formatter'
'coffee-fmt'
'clang-format'
'elm-format'
'htmlbeautifier'
'csscomb'
'gherkin'

22
src/languages/elm.coffee Normal file
View File

@ -0,0 +1,22 @@
module.exports = {
name: "Elm"
namespace: "elm"
###
Supported Grammars
###
grammars: [
"Elm"
]
###
Supported extensions
###
extensions: [
"elm"
]
options: []
}

View File

@ -21,6 +21,7 @@ module.exports = class Languages
"csv"
"d"
"ejs"
"elm"
"erb"
"gherkin"
"go"