From 14c1852f34fbdb582543c4be3c1480e5523f6ef4 Mon Sep 17 00:00:00 2001 From: Bjarke Vad Date: Mon, 23 Feb 2015 19:16:47 +0100 Subject: [PATCH] Added initial support for structured-haskell-mode --- contrib/lang/haskell/README.md | 19 +++++++++++++++++-- contrib/lang/haskell/config.el | 5 ++++- contrib/lang/haskell/packages.el | 18 +++++++++++++++++- 3 files changed, 38 insertions(+), 4 deletions(-) diff --git a/contrib/lang/haskell/README.md b/contrib/lang/haskell/README.md index eadcde027..d55089396 100644 --- a/contrib/lang/haskell/README.md +++ b/contrib/lang/haskell/README.md @@ -11,7 +11,9 @@ - [Layer](#layer) - [Cabal packages](#cabal-packages) - [OS X](#os-x) - - [Enabling GHCi-ng support](#enabling-ghci-ng-support) + - [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) @@ -23,6 +25,7 @@ + ## Description This layer adds support for the [Haskell][] language. @@ -84,7 +87,10 @@ so that the path is added before any layers is loaded. Note that `emacs.app` for OS X does not pick up `$PATH` from `~/.bashrc` or `~/.zshrc` when launched from outside a terminal. -### Enabling GHCi-ng support +### 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`, @@ -102,6 +108,14 @@ Once ghci-ng is enabled, two of the old keybindings are overriden with improved SPC m g g | go to definition SPC m u | 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 SPC m @@ -183,3 +197,4 @@ REPL commands are prefixed by SPC m s: [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 diff --git a/contrib/lang/haskell/config.el b/contrib/lang/haskell/config.el index 0d29f9a1f..4e8085650 100644 --- a/contrib/lang/haskell/config.el +++ b/contrib/lang/haskell/config.el @@ -11,4 +11,7 @@ ;; Variables (defvar haskell-ghci-ng-support nil - "If non nil ghci-ng support is enabled") + "If non-nil ghci-ng support is enabled") + +(defvar haskell-shm-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 e0434cd02..04f5b5c70 100644 --- a/contrib/lang/haskell/packages.el +++ b/contrib/lang/haskell/packages.el @@ -18,12 +18,25 @@ ghc haskell-mode hi2 + shm )) (defun haskell/init-flycheck () ;;(add-hook 'haskell-mode-hook 'flycheck-mode)) (add-hook 'flycheck-mode-hook 'flycheck-haskell-setup)) +(defun haskell/init-shm () + (use-package shm + :defer t + :if haskell-shm-support + :init + (add-hook 'haskell-mode-hook 'structured-haskell-mode) + :config + (progn + + ))) + + (defun haskell/init-haskell-mode () (require 'haskell-yas) (use-package haskell-mode @@ -139,7 +152,9 @@ (defun haskell-hook () (ghc-init) ;; Use advanced indention - (turn-on-haskell-indentation) + (if (not haskell-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 @@ -188,6 +203,7 @@ (use-package hi2 :diminish hi2-mode :commands turn-on-hi2 + :if (not haskell-shm-support) :init (add-hook 'haskell-mode-hook 'turn-on-hi2) :config