From 00a21e98f0b05d9497702395b37fc08522197d11 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Sun, 29 Mar 2020 18:28:20 -0400 Subject: [PATCH] Add +ghcide flag to lang/haskell Closes #2622 --- docs/modules.org | 2 +- modules/lang/haskell/+lsp.el | 10 +++++++--- modules/lang/haskell/README.org | 21 +++++++++++++-------- modules/lang/haskell/config.el | 17 +++++++++++------ 4 files changed, 32 insertions(+), 18 deletions(-) diff --git a/docs/modules.org b/docs/modules.org index 99d3c3a78..c93877eaf 100644 --- a/docs/modules.org +++ b/docs/modules.org @@ -107,7 +107,7 @@ Modules that bring support for a language or group of languages to Emacs. + [[file:../modules/lang/fsharp/README.org][fsharp]] - TODO + [[file:../modules/lang/fstar/README.org][fstar]] - F* support + [[file:../modules/lang/go/README.org][go]] =+lsp= - TODO -+ [[file:../modules/lang/haskell/README.org][haskell]] =+dante +intero +lsp= - TODO ++ [[file:../modules/lang/haskell/README.org][haskell]] =+dante +ghcide +lsp +intero= - TODO + hy - TODO + [[file:../modules/lang/idris/README.org][idris]] - TODO + java =+meghanada +lsp= - TODO diff --git a/modules/lang/haskell/+lsp.el b/modules/lang/haskell/+lsp.el index ae6339d55..16eb89bd6 100644 --- a/modules/lang/haskell/+lsp.el +++ b/modules/lang/haskell/+lsp.el @@ -1,10 +1,14 @@ ;;; lang/haskell/+lsp.el -*- lexical-binding: t; -*- (use-package! lsp-haskell - :after haskell-mode - :init (add-hook 'haskell-mode-hook #'lsp!) + :after lsp-clients + :init (add-hook 'haskell-mode-local-vars #'lsp!) :config (when IS-MAC (setq lsp-haskell-process-path-hie "hie-wrapper")) ;; Does some strange indentation if it pastes in the snippet - (setq-hook! 'haskell-mode-hook yas-indent-line 'fixed)) + (setq-hook! 'haskell-mode-hook yas-indent-line 'fixed) + + (when (featurep! +ghcide) + (setq lsp-haskell-process-path-hie "ghcide" + lsp-haskell-process-args-hie nil))) diff --git a/modules/lang/haskell/README.org b/modules/lang/haskell/README.org index bb4762289..b64d610b7 100644 --- a/modules/lang/haskell/README.org +++ b/modules/lang/haskell/README.org @@ -10,7 +10,8 @@ - [[#plugins][Plugins]] - [[#prerequisites][Prerequisites]] - [[#cabal][Cabal]] - - [[#lsp][LSP]] + - [[#lsp-haskell-ide-engine][LSP (haskell-ide-engine)]] + - [[#lsp-ghcide][LSP (ghcide)]] - [[#stack][Stack]] - [[#haskell-packages][Haskell packages]] - [[#configuration][Configuration]] @@ -18,8 +19,8 @@ - [[#troubleshooting][Troubleshooting]] * Description -This module adds [[https://www.haskell.org/][Haskell]] support, powered by either [[https://github.com/jyp/dante][dante]] (the default), LSP or -[[https://haskell-lang.org/intero][intero]]. +This module adds [[https://www.haskell.org/][Haskell]] support, powered by either [[https://github.com/jyp/dante][dante]] (the default), LSP +(haskell-language-server or ghcide) or [[https://haskell-lang.org/intero][intero]]. + Code completion (~company-ghc~) + Look up documentation (~hoogle~) @@ -41,7 +42,9 @@ Here are a few resources I've found indispensable in my Haskell adventures: + =+dante= Enables dante; a fork of intero aimed at lightweightedness. It doesn't depend on =stack=, supports both ~cabal~-only and ~stack~ projects, but lacks eldoc support. -+ =+lsp= Enables lsp-haskell (this requires the ~:tools lsp~ to be enabled). ++ =+ghcide= Enables LSP support with ghcide (requires the ~:tools lsp~ module). ++ =+lsp= Enables LSP support with haskell-ide-engine (requires the ~:tools lsp~ + module). + =+intero= (Deprecated) Enables intero; a comprehensive, stack-based development environment for Haskell. @@ -53,7 +56,7 @@ Here are a few resources I've found indispensable in my Haskell adventures: + =+lsp= + [[https://github.com/emacs-lsp/lsp-haskell][lsp-haskell]] + =+intero= - + [[https://github.com/chrisdone/intero][intero]] + + [[https://github.com/chrisdone/intero][intero]] =DEPRECATED= * Prerequisites Depending on whether you use Intero, Dante or LSP, your dependencies will @@ -83,7 +86,7 @@ sudo pacman -S cabal-install ghc sudo zypper install cabal-install ghc #+END_SRC -** LSP +** LSP (haskell-ide-engine) You will need =stack= and =git= installed. You will find a comprehensive [[https://github.com/haskell/haskell-ide-engine#installation][install guide for haskell-ide-engine on its @@ -92,7 +95,7 @@ project page]], but here's a TL;DR: *** MacOS haskell-ide-engine must be build and installed manually on MacOS, e.g. -#+BEGIN_SRC emacs-lisp +#+BEGIN_SRC bash git clone https://github.com/haskell/haskell-ide-engine cd haskell-ide-engine make @@ -101,9 +104,11 @@ make *** Arch Linux =haskell-ide-engine-git= is available on the AUR -#+BEGIN_SRC emacs-lisp +#+BEGIN_SRC bash yay -S haskell-ide-engine-git #+END_SRC +** LSP (ghcide) +See https://github.com/digital-asset/ghcide for install instructions. ** Stack To use Intero or LSP, you need =stack=: diff --git a/modules/lang/haskell/config.el b/modules/lang/haskell/config.el index a961d8cc0..689f3b852 100644 --- a/modules/lang/haskell/config.el +++ b/modules/lang/haskell/config.el @@ -3,14 +3,9 @@ (after! projectile (add-to-list 'projectile-project-root-files "stack.yaml")) -;; TODO ghcide? -(cond ((featurep! +intero) (load! "+intero")) ; DEPRECATED - ((featurep! +dante) (load! "+dante")) - ((featurep! +lsp) (load! "+lsp"))) - ;; -;; Common packages +;;; Common packages (after! haskell-mode (setq haskell-process-suggest-remove-import-lines t ; warnings for redundant imports etc @@ -45,3 +40,13 @@ "c" #'haskell-cabal-visit-file "h" #'haskell-hide-toggle "H" #'haskell-hide-toggle-all)) + + +;; +;;; Backends + +(cond ((featurep! +intero) (load! "+intero")) ; DEPRECATED + ((featurep! +dante) (load! "+dante")) + ((or (featurep! +lsp) + (featurep! +ghcide)) + (load! "+lsp")))