diff --git a/contrib/lang/haskell/README.md b/contrib/lang/haskell/README.md index e28098918..61b316edc 100644 --- a/contrib/lang/haskell/README.md +++ b/contrib/lang/haskell/README.md @@ -14,6 +14,7 @@ - [Optional extras](#optional-extras) - [GHCi-ng support](#ghci-ng-support) - [structured-haskell-mode](#structured-haskell-mode) + - [hindent](#hindent) - [Key bindings](#key-bindings) - [Haskell source code:](#haskell-source-code) - [Haskell commands:](#haskell-commands) @@ -115,6 +116,17 @@ To enable shm, run `cabal install structured-haskell-mode` and set the layer var ;; List of configuration layers to load. dotspacemacs-configuration-layers '(company-mode (haskell :variables haskell-enable-shm-support t) git) ``` +#### 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) +``` +By default it uses the style called `fundamental`, if you want to use +another, `johan-tibell`, run `M-x customize-variable +hindent-style`. ## Key bindings @@ -131,6 +143,7 @@ Top-level commands are prefixed by SPC m: SPC m i | gets information for the identifier under the cursor SPC m g g | go to definition or tag SPC m f | format buffer using haskell-stylish +SPC m F | format declaration using hindent (if enabled) #### Documentation commands: Documentation commands are prefixed by SPC m h @@ -198,3 +211,4 @@ REPL commands are prefixed by SPC m s: [hi2]: https://github.com/nilcons/hi2 [ghci-ng]: https://github.com/chrisdone/ghci-ng [structured-haskell-mode]: https://github.com/chrisdone/structured-haskell-mode +[hindent]: https://github.com/chrisdone/hindent diff --git a/contrib/lang/haskell/config.el b/contrib/lang/haskell/config.el index 6851b1132..d25efc339 100644 --- a/contrib/lang/haskell/config.el +++ b/contrib/lang/haskell/config.el @@ -15,3 +15,6 @@ (defvar haskell-enable-shm-support nil "If non-nil structured-haskell-mode support is enabled") + +(defvar haskell-enable-hindent-support nil + "If non-nil structured-haskell-mode support is enabled") diff --git a/contrib/lang/haskell/packages.el b/contrib/lang/haskell/packages.el index 9e70969b4..ceb9dec9d 100644 --- a/contrib/lang/haskell/packages.el +++ b/contrib/lang/haskell/packages.el @@ -18,9 +18,14 @@ ghc haskell-mode hi2 - shm )) +(when haskell-enable-shm-support + (add-to-list 'haskell-packages 'shm)) + +(when haskell-enable-hindent-support + (add-to-list 'haskell-packages 'hindent)) + (defun haskell/init-flycheck () ;;(add-hook 'haskell-mode-hook 'flycheck-mode)) (add-hook 'flycheck-mode-hook 'flycheck-haskell-setup)) @@ -30,12 +35,18 @@ :defer t :if haskell-enable-shm-support :init - (add-hook 'haskell-mode-hook 'structured-haskell-mode) + (add-hook 'haskell-mode-hook 'structured-haskell-mode))) + +(defun haskell/init-hindent () + (use-package hindent + :defer t + :if haskell-enable-hindent-support + :init + (add-hook 'haskell-mode-hook #'hindent-mode) :config (progn - - ))) - + (evil-leader/set-key-for-mode 'haskell-mode + "mF" 'hindent/reformat-decl)))) (defun haskell/init-haskell-mode () (require 'haskell-yas)