spacemacs/contrib/lang/haskell/README.md

201 lines
6.9 KiB
Markdown
Raw Normal View History

# Haskell contribution layer for Spacemacs
2014-12-24 06:03:49 +00:00
![logo](img/haskell.png)
<!-- 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)
- [Optional extras](#optional-extras)
- [GHCi-ng support](#ghci-ng-support)
- [structured-haskell-mode](#structured-haskell-mode)
- [Key bindings](#key-bindings)
- [Haskell source code:](#haskell-source-code)
- [Haskell commands:](#haskell-commands)
- [Documentation commands:](#documentation-commands)
- [Cabal commands:](#cabal-commands)
- [Debug commands:](#debug-commands)
- [REPL commands:](#repl-commands)
- [Cabal files:](#cabal-files)
<!-- markdown-toc end -->
## Description
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][].
**This layer is in construction, it needs your contributions and bug reports.**
## Install
### Layer
To use this contribution add it to your `~/.spacemacs`
```elisp
2015-02-18 03:36:12 +00:00
(setq-default dotspacemacs-configuration-layers '(haskell))
```
### Cabal packages
This layer requires some [cabal][] packages:
- `ghc-mod`
- `hlint`
- `stylish-haskell`
To install them, use the following command:
```sh
cabal install stylish-haskell hlint ghc-mod
```
Next Emacs needs to know where to find these binaries, you can locate them with
the following shell command:
```sh
dirname $(which ghc-mod)
```
Then you have to add this path to your system `$PATH` (preferred):
```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/")
```
**Note:** it is important to add the path in the `dotspacemacs/init` function,
so that the path is added before any layers is loaded.
### OS X
Note that `emacs.app` for OS X does not pick up `$PATH` from `~/.bashrc` or
`~/.zshrc` when launched from outside a terminal.
### Optional extras
The Haskell layer supports some extra features that can be enabled through layer variables.
#### GHCi-ng support
[ghci-ng][] adds some nice features to `haskell-mode`, and is supported in Spacemacs by a layer variable:
Follow the instructions to install [ghci-ng][] (remember to add `:set +c` in `~/.ghci`,
next set the layer variable:
```elisp
;; List of configuration layers to load.
dotspacemacs-configuration-layers '(company-mode (haskell :variables haskell-ghci-ng-support t) git)
```
Once ghci-ng is enabled, two of the old keybindings are overriden with improved versions from ghci-ng, and a new keybinding available:
Key Binding | Description
----------------------|------------------------------------------------------------
<kbd>SPC m t</kbd> | gets the type of the identifier under the cursor or for the active region
<kbd>SPC m g g</kbd> | go to definition
<kbd>SPC m u</kbd> | finds uses of identifier
#### structured-haskell-mode
[structured-haskell-mode][], or shm, replaces hi2 and adds some nice functionality.
To enable shm, run `cabal install structured-haskell-mode` and set the layer variable:
```elisp
;; List of configuration layers to load.
dotspacemacs-configuration-layers '(company-mode (haskell :variables haskell-shm-support t) git)
```
## Key bindings
All Haskell specific bindings are prefixed with <kbd>SPC m</kbd>
### Haskell source code:
#### Haskell commands:
Top-level commands are prefixed by <kbd>SPC m</kbd>:
2014-12-22 04:19:04 +00:00
Key Binding | Description
----------------------|------------------------------------------------------------
<kbd>SPC m t</kbd> | gets the type of the identifier under the cursor
<kbd>SPC m i</kbd> | gets information for the identifier under the cursor
<kbd>SPC m g g</kbd> | go to definition or tag
<kbd>SPC m f</kbd> | format buffer using haskell-stylish
#### Documentation commands:
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
<kbd>SPC m h y</kbd> | do a Hayoo lookup
#### Cabal commands:
Cabal commands are prefixed by <kbd>SPC m c</kbd>:
2014-12-22 04:19:04 +00:00
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`
2014-12-22 04:19:04 +00:00
<kbd>SPC m c v</kbd> | visit the cabal file
#### Debug commands:
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
<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
#### REPL commands:
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
### Cabal files:
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
[Haskell]: https://www.haskell.org/
[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
[ghci-ng]: https://github.com/chrisdone/ghci-ng
[structured-haskell-mode]: https://github.com/chrisdone/structured-haskell-mode