Updated haskell/shm bindings + misc haskell
- Added some shm keybindings that fit a bit better with evil-mode - Set better(saner at least) default for hindent style - Removed C-{<right>,<left>} bindings - Removed flycheck delay for showing error at point
This commit is contained in:
parent
83ea6cd2f3
commit
dda1e8de86
|
@ -89,19 +89,25 @@ 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.
|
||||
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:
|
||||
[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:
|
||||
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-enable-ghci-ng-support t) git)
|
||||
dotspacemacs-configuration-layers
|
||||
'(company-mode
|
||||
git
|
||||
(haskell :variables haskell-enable-ghci-ng-support t))
|
||||
```
|
||||
|
||||
Once ghci-ng is enabled, two of the old keybindings are overriden with improved versions from ghci-ng, and a new keybinding available:
|
||||
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
|
||||
----------------------|------------------------------------------------------------
|
||||
|
@ -110,19 +116,37 @@ Once ghci-ng is enabled, two of the old keybindings are overriden with improved
|
|||
<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:
|
||||
[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:
|
||||
```elisp
|
||||
;; List of configuration layers to load.
|
||||
dotspacemacs-configuration-layers '(company-mode (haskell :variables haskell-enable-shm-support t) git)
|
||||
```
|
||||
After shm has been enabled, some of the evil normal-mode bindings are overridden:
|
||||
|
||||
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][].
|
||||
|
||||
#### hindent
|
||||
[hindent]() is an extensible Haskell pretty printer, which let's you
|
||||
reformat your code. You need to install the executable with `cabal
|
||||
install hindent`; to enable it set:
|
||||
```elisp
|
||||
;; List of configuration layers to load.
|
||||
dotspacemacs-configuration-layers '(company-mode (haskell :variables haskell-enable-hindent-support t) git)
|
||||
dotspacemacs-configuration-layers
|
||||
'(company-mode
|
||||
git
|
||||
(haskell :variables haskell-enable-hindent-support t))
|
||||
```
|
||||
By default it uses the style called `fundamental`, if you want to use
|
||||
another, `johan-tibell`, run `M-x customize-variable
|
||||
|
|
|
@ -24,14 +24,49 @@
|
|||
|
||||
(defun haskell/init-flycheck ()
|
||||
(add-hook 'haskell-mode-hook 'flycheck-mode)
|
||||
(add-hook 'flycheck-mode-hook 'flycheck-haskell-setup))
|
||||
(add-hook 'flycheck-mode-hook 'flycheck-haskell-setup)
|
||||
(setq flycheck-display-errors-delay 0))
|
||||
|
||||
(defun haskell/init-shm ()
|
||||
(use-package shm
|
||||
:defer t
|
||||
:if haskell-enable-shm-support
|
||||
:init
|
||||
(add-hook 'haskell-mode-hook 'structured-haskell-mode)))
|
||||
(add-hook 'haskell-mode-hook 'structured-haskell-mode)
|
||||
:config
|
||||
(progn
|
||||
(when (require 'shm-case-split nil 'noerror)
|
||||
;;TODO: Find some better bindings for case-splits
|
||||
(define-key shm-map (kbd "C-c S") 'shm/case-split)
|
||||
(define-key shm-map (kbd "C-c C-s") 'shm/do-case-split))
|
||||
|
||||
(evil-define-key 'normal shm-map
|
||||
(kbd "RET") nil
|
||||
(kbd "C-k") nil
|
||||
(kbd "C-j") nil
|
||||
(kbd "D") 'shm/kill-line
|
||||
(kbd "R") 'shm/raise
|
||||
(kbd "P") 'shm/yank
|
||||
(kbd "RET") 'shm/newline-indent
|
||||
(kbd "RET") 'shm/newline-indent
|
||||
(kbd "M-RET") 'evil-ret
|
||||
)
|
||||
|
||||
(evil-define-key 'operator map
|
||||
(kbd ")") 'shm/forward-node
|
||||
(kbd "(") 'shm/backward-node
|
||||
)
|
||||
|
||||
(evil-define-key 'motion map
|
||||
(kbd ")") 'shm/forward-node
|
||||
(kbd "(") 'shm/backward-node
|
||||
)
|
||||
|
||||
(define-key shm-map (kbd "C-j") nil)
|
||||
(define-key shm-map (kbd "C-k") nil)
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
(defun haskell/init-hindent ()
|
||||
(use-package hindent
|
||||
|
@ -41,6 +76,7 @@
|
|||
(add-hook 'haskell-mode-hook #'hindent-mode)
|
||||
:config
|
||||
(progn
|
||||
(setq hindent-style "chris-done")
|
||||
(evil-leader/set-key-for-mode 'haskell-mode
|
||||
"mF" 'hindent/reformat-decl))))
|
||||
|
||||
|
@ -161,18 +197,7 @@
|
|||
(if (not haskell-enable-shm-support)
|
||||
(turn-on-haskell-indentation)
|
||||
)
|
||||
|
||||
;; Indent the below lines on columns after the current column.
|
||||
;; Might need better bindings for spacemacs and OS X
|
||||
(define-key haskell-mode-map (kbd "C-<right>")
|
||||
(lambda ()
|
||||
(interactive)
|
||||
(haskell-move-nested 1)))
|
||||
;; Same as above but backwards.
|
||||
(define-key haskell-mode-map (kbd "C-<left>")
|
||||
(lambda ()
|
||||
(interactive)
|
||||
(haskell-move-nested -1))))
|
||||
)
|
||||
|
||||
;; Useful to have these keybindings for .cabal files, too.
|
||||
(defun haskell-cabal-hook ()
|
||||
|
|
Loading…
Reference in a new issue