Merge branch 'master' of https://github.com/petrui/atom-beautify into petrui-master

This commit is contained in:
Glavin Wiechert 2016-04-23 16:47:22 -03:00
commit 0cf2ee5954
9 changed files with 221 additions and 1 deletions

View File

@ -74,4 +74,5 @@ before_install:
- brew install ocaml opam - brew install ocaml opam
- opam init --auto-setup - opam init --auto-setup
- opam install --yes ocp-indent - opam install --yes ocp-indent
# Crystal
- brew install crystal-lang

View File

@ -74,6 +74,7 @@ Or Settings/Preferences ➔ Packages ➔ Search for `atom-beautify`
- Requires [Elm-Format](https://github.com/avh4/elm-format) - Requires [Elm-Format](https://github.com/avh4/elm-format)
- [x] [Erlang](https://github.com/Glavin001/atom-beautify/pull/683) - [x] [Erlang](https://github.com/Glavin001/atom-beautify/pull/683)
- Requires erlang syntax_tools to be installed - Requires erlang syntax_tools to be installed
- [x] [Crystal](https://github.com/Glavin001/atom-beautify/pull/900)
## Usage ## Usage

View File

@ -1179,6 +1179,69 @@ Path to uncrustify config file. i.e. uncrustify.cfg (Supported by Uncrustify)
} }
``` ```
#### [Crystal](#crystal)
**Supported Beautifiers**: [`crystal`](#crystal)
**Description**:
Options for language Crystal
##### [Disable Beautifying Language](#disable-beautifying-language)
**Important**: This option is only configurable from within Atom Beautify's setting panel.
**Type**: `boolean`
**Description**:
Disable Crystal 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 "*Disable Beautifying Language*" and change it to your desired configuration.
##### [Default Beautifier](#default-beautifier)
**Important**: This option is only configurable from within Atom Beautify's setting panel.
**Default**: `crystal`
**Type**: `string`
**Enum**: `crystal`
**Description**:
Default Beautifier to be used for Crystal
**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 "*Default Beautifier*" and change it to your desired configuration.
##### [Beautify On Save](#beautify-on-save)
**Important**: This option is only configurable from within Atom Beautify's setting panel.
**Type**: `boolean`
**Description**:
Automatically beautify Crystal 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 "*Beautify On Save*" and change it to your desired configuration.
#### [C#](#c-) #### [C#](#c-)
**Supported Beautifiers**: [`Uncrustify`](#uncrustify) **Supported Beautifiers**: [`Uncrustify`](#uncrustify)

View File

@ -0,0 +1,49 @@
# A unicorn is a **legendary animal** (see the `Legendary` module) that has been
# described since antiquity as a beast with a large, spiraling horn projecting
# from its forhead.
#
# To create a unicorn:
#
# ```
# unicorn = Unicorn.new
# unicorn.speak
# ```
#
# The above produces:
#
# ```text
# "I'm a unicorn"
# ```
#
# Check the number of horns with `#horns`.
class Unicorn
include Legendary
# Creates a unicorn with the specified number of *horns*.
def initialize(@horns = 1)
raise "Not a unicorn" if @horns != 1
end
# Returns the number of horns this unicorn has
#
# ```
# Unicorn.new.horns # => 1
# ```
def horns
@horns
end
# ditto
def number_of_horns
horns
end
# Makes the unicorn speak to STDOUT
def speak
puts "I'm a unicorn"
end
# :nodoc:
class Helper
end
end

View File

@ -0,0 +1,49 @@
# A unicorn is a **legendary animal** (see the `Legendary` module) that has been
# described since antiquity as a beast with a large, spiraling horn projecting
# from its forhead.
#
# To create a unicorn:
#
# ```
# unicorn = Unicorn.new
# unicorn.speak
# ```
#
# The above produces:
#
# ```text
# "I'm a unicorn"
# ```
#
# Check the number of horns with `#horns`.
class Unicorn
include Legendary
# Creates a unicorn with the specified number of *horns*.
def initialize(@horns = 1)
raise "Not a unicorn" if @horns != 1
end
# Returns the number of horns this unicorn has
#
# ```
# Unicorn.new.horns # => 1
# ```
def horns
@horns
end
# ditto
def number_of_horns
horns
end
# Makes the unicorn speak to STDOUT
def speak
puts "I'm a unicorn"
end
# :nodoc:
class Helper
end
end

View File

@ -0,0 +1,33 @@
###
Requires https://github.com/jaspervdj/stylish-haskell
###
"use strict"
Beautifier = require('./beautifier')
module.exports = class Crystal extends Beautifier
name: "crystal"
options: {
Crystal: true
}
beautify: (text, language, options) ->
# Seems that Crystal dosen't have Windows support yet.
if @isWindows
@Promise.reject(@commandNotFoundError(
'crystal'
{
link: "http://crystal-lang.org"
program: "crystal"
})
)
else
@run("crystal", [
'tool',
'format',
tempFile = @tempFile("temp", text)
], {ignoreReturnCode: true})
.then(=>
@readFile(tempFile)
)

View File

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

View File

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

View File

@ -19,6 +19,7 @@ module.exports = class Languages
"coffeescript" "coffeescript"
"coldfusion" "coldfusion"
"cpp" "cpp"
"crystal"
"css" "css"
"csv" "csv"
"d" "d"