2014-12-02 04:22:45 +00:00
|
|
|
# Haskell contribution layer for Spacemacs
|
|
|
|
|
2014-12-24 06:03:49 +00:00
|
|
|
![logo](img/haskell.png)
|
2014-12-02 04:22:45 +00:00
|
|
|
|
2014-12-30 04:15:45 +00:00
|
|
|
<!-- markdown-toc start - Don't edit this section. Run M-x markdown-toc/generate-toc again -->
|
|
|
|
**Table of Contents**
|
|
|
|
|
|
|
|
- [Haskell contribution layer for Spacemacs](#haskell-contribution-layer-for-spacemacs)
|
|
|
|
- [Description](#description)
|
|
|
|
- [Install](#install)
|
|
|
|
- [Layer](#layer)
|
|
|
|
- [Cabal packages](#cabal-packages)
|
|
|
|
- [OS X](#os-x)
|
2015-02-23 18:16:47 +00:00
|
|
|
- [Optional extras](#optional-extras)
|
|
|
|
- [GHCi-ng support](#ghci-ng-support)
|
|
|
|
- [structured-haskell-mode](#structured-haskell-mode)
|
2015-02-25 16:56:31 +00:00
|
|
|
- [hindent](#hindent)
|
2014-12-30 04:15:45 +00:00
|
|
|
- [Key bindings](#key-bindings)
|
2015-03-18 12:52:06 +00:00
|
|
|
- [-](#-)
|
|
|
|
- [Debug](#debug)
|
|
|
|
- [REPL](#repl)
|
|
|
|
- [Cabal commands](#cabal-commands)
|
|
|
|
- [Cabal files](#cabal-files)
|
2014-12-30 04:15:45 +00:00
|
|
|
|
|
|
|
<!-- markdown-toc end -->
|
|
|
|
|
|
|
|
## Description
|
|
|
|
|
2014-12-02 04:22:45 +00:00
|
|
|
This layer adds support for the [Haskell][] language.
|
2015-01-01 07:11:51 +00:00
|
|
|
|
|
|
|
Features:
|
|
|
|
- auto-completion with [company-ghc][],
|
|
|
|
- auto-indentation with [hi2][].
|
2014-12-02 04:22:45 +00:00
|
|
|
|
2014-12-30 04:15:45 +00:00
|
|
|
**This layer is in construction, it needs your contributions and bug reports.**
|
2014-12-02 04:22:45 +00:00
|
|
|
|
|
|
|
## Install
|
|
|
|
|
2014-12-30 04:15:45 +00:00
|
|
|
### Layer
|
|
|
|
|
2014-12-02 04:22:45 +00:00
|
|
|
To use this contribution add it to your `~/.spacemacs`
|
|
|
|
|
|
|
|
```elisp
|
2015-02-18 03:36:12 +00:00
|
|
|
(setq-default dotspacemacs-configuration-layers '(haskell))
|
2014-12-02 04:22:45 +00:00
|
|
|
```
|
|
|
|
|
2014-12-30 04:15:45 +00:00
|
|
|
### Cabal packages
|
|
|
|
|
|
|
|
This layer requires some [cabal][] packages:
|
2014-12-24 14:18:02 +00:00
|
|
|
- `ghc-mod`
|
|
|
|
- `hlint`
|
|
|
|
- `stylish-haskell`
|
|
|
|
|
2014-12-30 04:15:45 +00:00
|
|
|
To install them, use the following command:
|
|
|
|
|
|
|
|
```sh
|
|
|
|
cabal install stylish-haskell hlint ghc-mod
|
|
|
|
```
|
|
|
|
|
|
|
|
Then you have to add this path to your system `$PATH` (preferred):
|
2015-03-28 14:16:33 +00:00
|
|
|
Note that on **Linux** distributions the installed binaries should be in
|
|
|
|
`~/.cabal/bin` and on **OS X** the binaries are installed in
|
|
|
|
`/Users/<username>/Library/Haskell/bin`.
|
2014-12-30 04:15:45 +00:00
|
|
|
|
|
|
|
```sh
|
|
|
|
export PATH=~/.cabal/bin/:$PATH
|
|
|
|
```
|
|
|
|
|
|
|
|
_or_ to the Emacs `exec-path` variable in the `dotspacemacs/init` function of
|
|
|
|
your `.spacemacs` file:
|
|
|
|
|
|
|
|
```elisp
|
|
|
|
(add-to-list 'exec-path "~/.cabal/bin/")
|
|
|
|
```
|
2014-12-24 14:18:02 +00:00
|
|
|
|
2014-12-30 04:15:45 +00:00
|
|
|
**Note:** it is important to add the path in the `dotspacemacs/init` function,
|
|
|
|
so that the path is added before any layers is loaded.
|
2014-12-24 14:18:02 +00:00
|
|
|
|
2014-12-30 04:15:45 +00:00
|
|
|
### OS X
|
2014-12-24 14:18:02 +00:00
|
|
|
|
2014-12-30 04:15:45 +00:00
|
|
|
Note that `emacs.app` for OS X does not pick up `$PATH` from `~/.bashrc` or
|
|
|
|
`~/.zshrc` when launched from outside a terminal.
|
2014-12-24 14:18:02 +00:00
|
|
|
|
2015-02-23 18:16:47 +00:00
|
|
|
### Optional extras
|
2015-03-01 18:39:25 +00:00
|
|
|
The Haskell layer supports some extra features that can be enabled through
|
|
|
|
layer variables.
|
2015-02-23 18:16:47 +00:00
|
|
|
|
|
|
|
#### GHCi-ng support
|
2015-03-01 18:39:25 +00:00
|
|
|
[ghci-ng][] adds some nice features to `haskell-mode`, and is supported in
|
|
|
|
Spacemacs by a layer variable:
|
2015-02-22 11:03:46 +00:00
|
|
|
|
2015-03-01 18:39:25 +00:00
|
|
|
Follow the instructions to install [ghci-ng][] (remember to add `:set +c`
|
|
|
|
in `~/.ghci`, next set the layer variable:
|
2015-03-16 05:56:28 +00:00
|
|
|
|
2015-02-22 11:03:46 +00:00
|
|
|
```elisp
|
2015-03-16 05:56:28 +00:00
|
|
|
(setq-default dotspacemacs-configuration-layers
|
|
|
|
'((haskell :variables haskell-enable-ghci-ng-support t)))
|
2015-02-22 11:03:46 +00:00
|
|
|
```
|
|
|
|
|
2015-03-01 18:39:25 +00:00
|
|
|
Once ghci-ng is enabled, two of the old keybindings are overriden with improved
|
|
|
|
versions from ghci-ng, and a new keybinding available:
|
2015-02-22 11:03:46 +00:00
|
|
|
|
|
|
|
Key Binding | Description
|
|
|
|
----------------------|------------------------------------------------------------
|
2015-03-29 13:58:35 +00:00
|
|
|
<kbd>SPC m h t</kbd> | gets the type of the identifier under the cursor or for the active region
|
2015-02-22 11:03:46 +00:00
|
|
|
<kbd>SPC m g g</kbd> | go to definition
|
|
|
|
<kbd>SPC m u</kbd> | finds uses of identifier
|
|
|
|
|
2015-02-23 18:16:47 +00:00
|
|
|
#### structured-haskell-mode
|
2015-03-01 18:39:25 +00:00
|
|
|
[structured-haskell-mode][], or shm, replaces hi2 (and any other
|
|
|
|
Haskell-indentation modes) and adds some nice functionality.
|
|
|
|
To enable shm, run `cabal install structured-haskell-mode` and set the layer
|
|
|
|
variable:
|
2015-03-16 05:56:28 +00:00
|
|
|
|
2015-02-23 18:16:47 +00:00
|
|
|
```elisp
|
2015-03-16 05:56:28 +00:00
|
|
|
(setq-default dotspacemacs-configuration-layers
|
|
|
|
'((haskell :variables haskell-enable-shm-support t)))
|
2015-02-23 18:16:47 +00:00
|
|
|
```
|
2015-03-16 05:56:28 +00:00
|
|
|
|
2015-03-18 12:52:06 +00:00
|
|
|
After shm has been enabled, some of the evil normal state bindings are overridden:
|
2015-03-01 18:39:25 +00:00
|
|
|
|
|
|
|
Key Binding | Description
|
|
|
|
----------------------|------------------------------------------------------------
|
|
|
|
<kbd>D</kbd> | `shm/kill-line`
|
|
|
|
<kbd>R</kbd> | `shm/raise`
|
|
|
|
<kbd>P</kbd> | `shm/yank`
|
|
|
|
<kbd>(</kbd> | `shm/forward-node`
|
|
|
|
<kbd>)</kbd> | `shm/backward-node`
|
|
|
|
|
|
|
|
For a nice visualization of these functions, please refer to the github page
|
|
|
|
for [structured-haskell-mode][].
|
|
|
|
|
2015-02-25 16:56:31 +00:00
|
|
|
#### hindent
|
2015-03-16 05:56:28 +00:00
|
|
|
[hindent][] is an extensible Haskell pretty printer, which let's you
|
2015-02-25 16:56:31 +00:00
|
|
|
reformat your code. You need to install the executable with `cabal
|
2015-03-16 05:56:28 +00:00
|
|
|
install hindent`.
|
|
|
|
|
2015-03-28 12:34:19 +00:00
|
|
|
To enable it you have to set the variable `haskell-enable-hindent-style`
|
2015-03-16 05:56:28 +00:00
|
|
|
to a supported style. The available styles are:
|
|
|
|
- fundamental
|
|
|
|
- johan-tibell
|
|
|
|
- chris-done
|
|
|
|
- andrew-gibiansky
|
|
|
|
|
|
|
|
See examples [here][hindent-examples]
|
|
|
|
|
2015-02-25 16:56:31 +00:00
|
|
|
```elisp
|
2015-03-16 05:56:28 +00:00
|
|
|
(setq-default dotspacemacs-configuration-layers
|
2015-03-28 12:34:19 +00:00
|
|
|
'((haskell :variables haskell-enable-hindent-style "johan-tibell")))
|
2015-02-25 16:56:31 +00:00
|
|
|
```
|
2015-03-16 05:56:28 +00:00
|
|
|
|
2014-12-02 04:22:45 +00:00
|
|
|
## Key bindings
|
|
|
|
|
2015-03-18 12:52:06 +00:00
|
|
|
All Haskell specific bindings are prefixed with the major-mode leader
|
|
|
|
<kbd>SPC m</kbd>.
|
2014-12-21 16:03:27 +00:00
|
|
|
|
|
|
|
Top-level commands are prefixed by <kbd>SPC m</kbd>:
|
|
|
|
|
2014-12-22 04:19:04 +00:00
|
|
|
Key Binding | Description
|
|
|
|
----------------------|------------------------------------------------------------
|
2015-02-22 11:03:46 +00:00
|
|
|
<kbd>SPC m g g</kbd> | go to definition or tag
|
2014-12-22 10:49:15 +00:00
|
|
|
<kbd>SPC m f</kbd> | format buffer using haskell-stylish
|
2015-02-25 16:56:31 +00:00
|
|
|
<kbd>SPC m F</kbd> | format declaration using hindent (if enabled)
|
2014-12-21 16:03:27 +00:00
|
|
|
|
2015-03-18 12:52:06 +00:00
|
|
|
### Documentation
|
|
|
|
|
2014-12-21 16:03:27 +00:00
|
|
|
Documentation commands are prefixed by <kbd>SPC m h</kbd>
|
|
|
|
|
2014-12-22 04:19:04 +00:00
|
|
|
Key Binding | Description
|
|
|
|
----------------------|------------------------------------------------------------
|
|
|
|
<kbd>SPC m h d</kbd> | find or generate Haddock documentation for the identifier under the cursor
|
|
|
|
<kbd>SPC m h h</kbd> | do a Hoogle lookup
|
2015-03-18 12:52:06 +00:00
|
|
|
<kbd>SPC m h i</kbd> | gets information for the identifier under the cursor
|
|
|
|
<kbd>SPC m h t</kbd> | gets the type of the identifier under the cursor
|
2014-12-22 04:19:04 +00:00
|
|
|
<kbd>SPC m h y</kbd> | do a Hayoo lookup
|
2014-12-21 16:03:27 +00:00
|
|
|
|
2015-03-18 12:52:06 +00:00
|
|
|
### Debug
|
2014-12-21 16:03:27 +00:00
|
|
|
|
|
|
|
Debug commands are prefixed by <kbd>SPC m d</kbd>:
|
|
|
|
|
2014-12-22 04:19:04 +00:00
|
|
|
Key Binding | Description
|
|
|
|
----------------------|------------------------------------------------------------
|
|
|
|
<kbd>SPC m d d </kbd> | start debug process, needs to be run first
|
|
|
|
<kbd>SPC m d b </kbd> | insert breakpoint at function
|
|
|
|
<kbd>SPC m d n </kbd> | next breakpoint
|
2014-12-22 10:49:15 +00:00
|
|
|
<kbd>SPC m d N </kbd> | previous breakpoint
|
2014-12-22 04:19:04 +00:00
|
|
|
<kbd>SPC m d B </kbd> | delete breakpoint
|
|
|
|
<kbd>SPC m d c </kbd> | continue current process
|
|
|
|
<kbd>SPC m d a </kbd> | abandon current process
|
|
|
|
<kbd>SPC m d r </kbd> | refresh process buffer
|
2014-12-21 16:03:27 +00:00
|
|
|
|
2015-03-18 12:52:06 +00:00
|
|
|
### REPL
|
|
|
|
|
2014-12-21 16:03:27 +00:00
|
|
|
REPL commands are prefixed by <kbd>SPC m s</kbd>:
|
|
|
|
|
2014-12-22 04:19:04 +00:00
|
|
|
Key Binding | Description
|
|
|
|
----------------------|------------------------------------------------------------
|
|
|
|
<kbd>SPC m s b</kbd> | load or reload the current buffer into the REPL
|
|
|
|
<kbd>SPC m s c</kbd> | clear the REPL
|
|
|
|
<kbd>SPC m s s</kbd> | show the REPL
|
|
|
|
<kbd>SPC m s S</kbd> | show and switch to the REPL
|
2014-12-21 16:03:27 +00:00
|
|
|
|
2015-03-18 12:52:06 +00:00
|
|
|
### Cabal commands
|
|
|
|
|
|
|
|
Cabal commands are prefixed by <kbd>SPC m c</kbd>:
|
|
|
|
|
|
|
|
Key Binding | Description
|
|
|
|
----------------------|------------------------------------------------------------
|
|
|
|
<kbd>SPC m c a</kbd> | cabal actions
|
|
|
|
<kbd>SPC m c b</kbd> | build the current cabal project, i.e. invoke `cabal build`
|
|
|
|
<kbd>SPC m c c</kbd> | compile the current project, i.e. invoke `ghc`
|
|
|
|
<kbd>SPC m c v</kbd> | visit the cabal file
|
|
|
|
|
|
|
|
### Cabal files
|
|
|
|
|
|
|
|
This commands are available in a cabal file.
|
2014-12-21 16:03:27 +00:00
|
|
|
|
2014-12-22 04:19:04 +00:00
|
|
|
Key Binding | Description
|
|
|
|
----------------------|------------------------------------------------------------
|
|
|
|
<kbd>SPC m d</kbd> | add a dependency to the project
|
|
|
|
<kbd>SPC m b</kbd> | go to benchmark section
|
|
|
|
<kbd>SPC m e</kbd> | go to executable section
|
|
|
|
<kbd>SPC m t</kbd> | go to test-suite section
|
|
|
|
<kbd>SPC m m</kbd> | go to exposed modules
|
|
|
|
<kbd>SPC m l</kbd> | go to libary section
|
|
|
|
<kbd>SPC m n</kbd> | go to next subsection
|
|
|
|
<kbd>SPC m p</kbd> | go to previous subsection
|
|
|
|
<kbd>SPC m N</kbd> | go to next section
|
|
|
|
<kbd>SPC m P</kbd> | go to previous section
|
|
|
|
<kbd>SPC m f</kbd> | find or create source-file under the cursor
|
2014-12-21 16:03:27 +00:00
|
|
|
|
2014-12-02 04:22:45 +00:00
|
|
|
[Haskell]: https://www.haskell.org/
|
2014-12-30 04:15:45 +00:00
|
|
|
[cabal]: https://www.haskell.org/cabal/
|
2015-01-01 07:11:51 +00:00
|
|
|
[company-ghc]: https://github.com/iquiw/company-ghc
|
|
|
|
[hi2]: https://github.com/nilcons/hi2
|
2015-02-22 11:03:46 +00:00
|
|
|
[ghci-ng]: https://github.com/chrisdone/ghci-ng
|
2015-02-23 18:16:47 +00:00
|
|
|
[structured-haskell-mode]: https://github.com/chrisdone/structured-haskell-mode
|
2015-02-25 16:56:31 +00:00
|
|
|
[hindent]: https://github.com/chrisdone/hindent
|
2015-03-16 05:56:28 +00:00
|
|
|
[hindent-examples]: https://github.com/chrisdone/hindent#example
|