From 0e78cde69d1e42bd802c35990e55364d4577a1cd Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Thu, 25 May 2017 20:09:36 +0200 Subject: [PATCH] lang/haskell: refactor + add company-ghc --- modules/lang/haskell/config.el | 25 +++++++++++++++++-------- modules/lang/haskell/packages.el | 5 +++-- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/modules/lang/haskell/config.el b/modules/lang/haskell/config.el index 45b574f84..90b59307b 100644 --- a/modules/lang/haskell/config.el +++ b/modules/lang/haskell/config.el @@ -1,18 +1,16 @@ ;;; module-haskell.el -;; requires cabal (flycheck), ghci/hugs (repl) - (def-package! haskell-mode - :mode (("\\.hs$" . haskell-mode) - ("\\.ghci$" . ghci-script-mode) - ("\\.cabal$" . haskell-cabal-mode)) + :mode "\\.hs$" + :mode ("\\.ghci$" . ghci-script-mode) + :mode ("\\.cabal$" . haskell-cabal-mode) :interpreter (("runghc" . haskell-mode) ("runhaskell" . haskell-mode)) :config (load "haskell-mode-autoloads" nil t) - (set! :popup "*debug:haskell*" :size 20) (set! :repl 'haskell-mode #'switch-to-haskell) + (push ".hi" completion-ignored-extensions) (autoload 'switch-to-haskell "inf-haskell" nil t) @@ -23,7 +21,18 @@ (def-package! dante :after haskell-mode :config - (when (executable-find "cabal") + (if (executable-find "cabal") (add-hook! 'haskell-mode-hook - #'(flycheck-mode dante-mode interactive-haskell-mode)))) + #'(flycheck-mode dante-mode interactive-haskell-mode)) + (warn "haskell-mode: couldn't find cabal"))) + +(def-package! company-ghc + :when (featurep! :completion company) + :after haskell-mode + :config + (set! :company-backend 'haskell-mode #'company-ghc) + (setq company-ghc-show-info 'oneline) + (if (executable-find "ghc-mod") + (add-hook 'haskell-mode-hook #'ghc-comp-init) + (warn "haskell-mode: couldn't find ghc-mode"))) diff --git a/modules/lang/haskell/packages.el b/modules/lang/haskell/packages.el index 14810b2ff..666cd7127 100644 --- a/modules/lang/haskell/packages.el +++ b/modules/lang/haskell/packages.el @@ -1,7 +1,8 @@ ;; -*- no-byte-compile: t; -*- ;;; lang/haskell/packages.el -;; requires haskell cabal-install ghz happy alex - (package! haskell-mode) (package! dante) + +(when (featurep! :completion company) + (package! company-ghc))