Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nukisman/elm-format-short
elm-format-short formats Elm source code according to a standard set of rules in shorter way than elm-format.
https://github.com/nukisman/elm-format-short
elm elm-format elm-lang elm-language format formatter source-code
Last synced: 3 months ago
JSON representation
elm-format-short formats Elm source code according to a standard set of rules in shorter way than elm-format.
- Host: GitHub
- URL: https://github.com/nukisman/elm-format-short
- Owner: nukisman
- License: bsd-3-clause
- Fork: true (avh4/elm-format)
- Created: 2017-09-23T07:15:53.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-10-02T00:55:44.000Z (about 7 years ago)
- Last Synced: 2024-09-25T22:46:04.437Z (3 months ago)
- Topics: elm, elm-format, elm-lang, elm-language, format, formatter, source-code
- Language: Haskell
- Homepage: https://npmjs.com/package/elm-format-short
- Size: 2.28 MB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# elm-format-short
> `elm-format-short` is still in alpha. If you run into any problems, please [report them](https://github.com/nukisman/elm-format-short/issues).
>
> **The format produced by elm-format-short may change significantly before the 1.0.0 release.**
If this will cause problems for you, please refrain from using elm-format-short during the alpha- and beta-test periods.See [https://github.com/nukisman/elm-format-short](https://github.com/nukisman/elm-format-short)
`elm-format-short` formats your code like `elm-format` but:
* Without extra blank lines
* Without extra line breaks
* Without extra indents
* With shorter and better visual representations of `case-of`, `if-then-else`, `let-in`, etc.
`elm-format-short` formats [Elm](http://elm-lang.org) source code according to a standard set of rules in shorter way than `elm-format`.The benefits of `elm-format-short` are same as of `elm-format`:
- It makes code **easier to write**, because you never have to worry about minor formatting concerns while powering out new code.
- It makes code **easier to read**, because there are no longer distracting minor stylistic differences between different code bases. As such, your brain can map more efficiently from source to mental model.
- It makes code **easier to maintain**, because you can no longer have diffs related only to formatting; every diff necessarily involves a material change.
- It **saves your team time** debating how to format things, because there is a standard tool that formats everything the same way.
- It **saves you time** because you don't have to nitpick over formatting details of your code.plus benefits in contrast to `elm-format`:
- It makes code **easier to read**, because you can see more code without scrolling.
- It makes code **easier to navigate**, because you have not to scroll needless empty space by mouse or arrows on keyboard.
- It makes code **easier to write**, because it is **easier to read** and **easier to navigate**.
- It makes code **easier to debug**, because your lines of code commented out for debug purposes are not surrounded by needless blank lines above and below.
- It **saves your money**, because you can still use your display. It not require you to buy new display with vertical resolution of 1000000000 pixels to see tons of blank lines.## Example formatting
See `dreamwriter` app by `@rtfeldman`:
- [Editor.elm](tests/test-files/good/rtfeldman/dreamwriter/Editor.elm)
- [LeftSidebar.elm](tests/test-files/good/rtfeldman/dreamwriter/LeftSidebar.elm)
- [RightSidebar.elm](tests/test-files/good/rtfeldman/dreamwriter/RightSidebar.elm)
- [WordGraph.elm](tests/test-files/good/rtfeldman/dreamwriter/WordGraph.elm)
## Usage (same as elm-format)```bash
elm-format-short Main.elm # Format a single file
elm-format-short Main.elm --yes # Overwrite the file without prompting
elm-format-short src/ # Format all *.elm files in a directory
elm-format-short --stdin # Format input from stdin and write to stdout
elm-format-short --stdin --output Main.elm # Format input from stdin and write to file
elm-format-short --help # See other command line options
```---
## Installation (currently Mac and Linux only)
`npm i -g elm-format-short`
## IDE Integration
`elm-format-short` is CLI-compatible with `elm-format`. IDE Integration almost same as for `elm-format`.
### JetBrains Integration
This is for WebStorm and other JetBrains IDEs.
1. Install `elm-format-short`
1. Install the [Elm Language Plugin](https://durkiewicz.github.io/elm-plugin/) package.
1. Install the File Watchers plugin (available in the plugin repository)
1. Add a file watcher for .elm files with the settings as [shown here](img/JetBrains%20setup.png).
1. Set tab/indent size to 2 spaces as [shown here](img/JetBrains%20setup%20tabsize.png)
------
# TODO: Update this document for elm-format-short
### Experimental version
The latest version of `elm-format` contains experimental features that may or may not appear in future releases.
If you are able to some amount of instability on your Elm projects,
you can help with the development of `elm-format` by using the experimental version and providing feedback.
You can give feedback about the latest experimental version [here](https://goo.gl/forms/kLdTN1yikfOI8ZuA3).To install the experimental version:
```sh
npm install -g elm-format@exp
```or download the version appropriate for your OS from the [release page](https://github.com/avh4/elm-format/releases/tag/0.7.0-exp),
unzip it,
and place `elm-format` or `elm-format.exe` (windows) on your `PATH`.## Editor integration
Find your editor in the table below. The recommended plugin for each editor is indicated with :trophy: (trophy emoji).
Editor
Plugin
Installation
Formatting
Format on save
Configuration
Error handling
Atom
:trophy: atom-elm-format
:white_check_mark: 2 steps
:warning: must use format-on-save or save file before formatting
:white_check_mark:
:white_check_mark:
:warning: no installation instructions
atom-beautify
:warning: 3 steps
:white_check_mark:
:warning: requires configuration
:white_check_mark:
:white_check_mark:
Light Table
:trophy: elm-light
:warning: 3 steps
:white_check_mark:
:warning: requires configuration
:white_check_mark:
:warning: no installation instructions
Vim
:trophy: elm-vim
:x: 6 steps
:white_check_mark:
⚠️ requires configuration
:white_check_mark:
:x: no error message
Emacs
:trophy: elm-mode
:x: 4 steps
:white_check_mark:
:warning: requires configuration
:white_check_mark:
:warning: no installation instructions
Visual Studio Code
:trophy: Elm Language Support
:warning: 3 steps
❔ TBD
:warning: requires configuration
❔ TBD
❔ TBD
VSCode Elm Format
:warning: 3 steps
❔ TBD
:warning: requires configuration
❔ TBD
❔ TBD
Sublime Text
:trophy: Elm Language Support
:white_check_mark: 2 steps
❔ TBD
:white_check_mark:
❔ TBD
❔ TBD
JetBrains (WebStorm, etc)
:trophy: Elm Language Plugin
:warning: 4 steps
❔ TBD
:white_check_mark:
❔ TBD
❔ TBD
## Detailed instructions
If you can simplify or improve the installation instructions or add instructions for another editor, please [make a pull request](https://github.com/avh4/elm-format/edit/master/README.md).
The default behavior of `elm-format`-approved plugins is to format Elm files on save.### atom-elm-format installation
1. Install elm-format
1. Install atom-elm-format```
apm install elm-format
```or use the Atom package manager in Atom's settings
### atom-beautify installation
1. Install elm-format
1. Install atom-beautify```
apm install atom-beautify
```or use the Atom package manager in Atom's settings
1. Use `^⌥B` (`CTRL-ALT-B`) to format a file
### elm-light installation
1. Install elm-format
1. Install the [elm-light plugin](https://github.com/rundis/elm-light) using the Light Table plugin manager
1. To format on save, edit your user keymap by performing the following:
* Click File -> Settings -> User Keymap to open the user keymap.
* Copy the following line and paste it into your keymap. Anywhere is fine as long as it is whithin the outer brackets. Ensure to save the file.
```clojure
[:editor.elm "ctrl-s" :save :elm-format :elm.lint]
```
* Search for "App: Reload keymaps" in the Commands Window to apply the changes (or restart LightTable).### elm-mode installation
1. Install elm-format
1. If your Emacs has `package.el` (which is automatically the case for Emacs >= 24), you can install `elm-mode` from the package in [MELPA](http://melpa.milkbox.net/):1. Ensure that you have added the MELPA source in your `~/.emacs.d/init.el`:
```lisp
(require 'package)
(add-to-list 'package-archives '("melpa" . "http://melpa.org/packages/"))
```1. Install elm-mode ([official instructions](https://github.com/jcollard/elm-mode#installation)): Use `M-x list-packages` and choose `elm-mode`.
1. Set `elm-format-on-save` to `t` to apply elm-format on the current buffer on every save. (The setting can be changed via `M-x customize-variable elm-format-on-save`. Click button `Toggle` to change the setting and button `State` to activate the setting.)
### elm-vim installation
1. Install elm-format
1. Install [vim-plug](https://github.com/junegunn/vim-plug) ([official instructions](https://github.com/junegunn/vim-plug#installation))1. Download vim-plug:
```bash
curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
```1. Make sure there is a section like this in your `~/.vimrc`:
```vim
call plug#begin('~/.vim/plugged')
" ... any active plugins
call plug#end()
```1. Install elm-vim ([official instructions](https://github.com/ElmCast/elm-vim#install))
1. Add `Plug 'elmcast/elm-vim'` to the `plug#begin` plugin section in your `~/.vimrc`
1. Start `vim` and run `:PlugInstall`1. Add the following to your `~/.vimrc`:
```
let g:elm_format_autosave = 1
```### Visual Studio Code installation
1. Install elm-format
1. Install Elm tools for VSCode```bash
ext install elm
```1. SHIFT-ALT-F will format the current file
### VSCode Elm Format installation
1. Install elm-format
1. Install VSCode Elm Format```bash
ext install elm-format
```1. You can run elm-format by using the `Elm: Format` command
1. You can also run elm-format whenever you save the file by adding `formatOnSave: true` option to your [settings.json](https://code.visualstudio.com/docs/customization/userandworkspace) file.### Sublime Text installation
1. Install elm-format
1. Install the [Elm Language Support](https://packagecontrol.io/packages/Elm%20Language%20Support) package.### JetBrains installation
This is for WebStorm and other JetBrains IDEs.
1. Install elm-format
1. Install the [Elm Language Plugin](https://durkiewicz.github.io/elm-plugin/) package.
1. Install the File Watchers plugin (available in the plugin repository)
1. Add a file watcher for .elm files with the settings as [shown here](img/JetBrains%20setup.png).## Development info
Please note that this project is released with a [Contributor Code of Conduct](CODE_OF_CONDUCT.md). By participating in this project you agree to abide by its terms.
### Building from source
```bash
brew install haskell-stack
git clone https://github.com/avh4/elm-format.git
cd elm-format
stack setup
stack build
stack install
~/.local/bin/elm-format-0.18 --help
```### Running tests
```bash
brew install shellcheck
./tests/run-tests.sh
```