Updating Doom Emacs.

This commit is contained in:
Derek Taylor
2020-06-19 22:43:40 -05:00
parent 0f664d532a
commit a5c86c514a
453 changed files with 13527 additions and 12455 deletions

View File

@@ -14,7 +14,7 @@
"-fdefer-typed-holes"
"-fdefer-type-errors"))
:config
(when (featurep! :tools flycheck)
(when (featurep! :checkers syntax)
(flycheck-add-next-checker 'haskell-dante '(warning . haskell-hlint)))
(set-company-backend! 'dante-mode #'dante-company)
@@ -36,6 +36,6 @@ reformatting)."
:localleader
"t" #'dante-type-at
"i" #'dante-info
"l" #'haskell-process-load-or-reload
"l" #'haskell-process-load-file
"e" #'dante-eval-block
"a" #'attrap-attrap))

View File

@@ -1,30 +0,0 @@
;;; lang/haskell/+intero.el -*- lexical-binding: t; -*-
;;;###if (featurep! +intero)
(use-package! intero
:commands intero-mode
:init
(add-hook! 'haskell-mode-local-vars-hook
(defun +haskell-init-intero-h ()
"Initializes `intero-mode' in haskell-mode, unless stack isn't installed.
This is necessary because `intero-mode' doesn't do its own error checks."
(when (derived-mode-p 'haskell-mode)
(if (executable-find "stack")
(intero-mode +1)
(message "Couldn't find stack. Refusing to enable intero-mode.")))))
:config
(setq haskell-compile-cabal-build-command "stack build --fast")
(set-lookup-handlers! 'intero-mode :definition #'intero-goto-definition)
(set-company-backend! 'intero-mode 'intero-company)
(when (featurep! :tools flycheck)
(flycheck-add-next-checker 'intero '(warning . haskell-hlint)))
(when (featurep 'evil)
(add-hook 'intero-mode-hook #'evil-normalize-keymaps))
(map! :localleader
:map intero-mode-map
"t" #'intero-type-at
"i" #'intero-info
"l" #'intero-repl-load
"e" #'intero-repl-eval-region
"a" #'intero-apply-suggestions))

View File

@@ -1,10 +1,13 @@
;;; lang/haskell/+lsp.el -*- lexical-binding: t; -*-
(use-package! lsp-haskell
:after haskell-mode
:init (add-hook 'haskell-mode-hook #'lsp!)
:after lsp-clients
:preface (add-hook 'haskell-mode-local-vars-hook #'lsp!)
:config
(when IS-MAC
(setq lsp-haskell-process-path-hie "hie-wrapper"))
(when (featurep! +ghcide)
(setq lsp-haskell-process-path-hie "ghcide"
lsp-haskell-process-args-hie nil))
;; Does some strange indentation if it pastes in the snippet
(setq-hook! 'haskell-mode-hook yas-indent-line 'fixed))

View File

@@ -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) or LSP
(haskell-language-server or ghcide).
+ Code completion (~company-ghc~)
+ Look up documentation (~hoogle~)
@@ -41,9 +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).
+ =+intero= (Deprecated) Enables intero; a comprehensive, stack-based
development environment for Haskell.
+ =+ghcide= Enables LSP support with ghcide (requires the ~:tools lsp~ module).
+ =+lsp= Enables LSP support with haskell-ide-engine (requires the ~:tools lsp~
module).
** Plugins
+ [[https://github.com/haskell/haskell-mode][haskell-mode]]
@@ -52,16 +53,13 @@ Here are a few resources I've found indispensable in my Haskell adventures:
+ [[https://github.com/jyp/attrap][attrap]]
+ =+lsp=
+ [[https://github.com/emacs-lsp/lsp-haskell][lsp-haskell]]
+ =+intero=
+ [[https://github.com/chrisdone/intero][intero]]
* Prerequisites
Depending on whether you use Intero, Dante or LSP, your dependencies will
differ:
Depending on whether you use Dante, haskell-language-server or ghcide, your
dependencies will differ:
+ Dante users need =cabal=, =ghc= and =ghc-mod=
+ LSP users need the =haskell-ide-engine= LSP server
+ Intero and LSP users need =stack=
+ LSP users need the =haskell-ide-engine= LSP server OR =ghcide=
+ All users will need the =hoogle= package
** Cabal
@@ -83,7 +81,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 +90,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,12 +99,14 @@ 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=:
To use LSP, you need =stack=:
*** MacOS
#+BEGIN_SRC sh

View File

@@ -4,11 +4,25 @@
(defun +haskell/open-repl (&optional arg)
"Opens a Haskell REPL."
(interactive "P")
(if-let*
((window
(display-buffer
(if (featurep! +intero)
(intero-repl-buffer arg)
(haskell-session-interactive-buffer (haskell-session))))))
(if-let (window
(display-buffer
(haskell-session-interactive-buffer (haskell-session))))
(window-buffer window)
(error "Failed to display Haskell REPL")))
;;;###autoload
(defun +haskell/evil-open-above ()
"Opens a line above the current mode"
(interactive)
(evil-digit-argument-or-evil-beginning-of-line)
(haskell-indentation-newline-and-indent)
(evil-previous-line)
(haskell-indentation-indent-line)
(evil-append-line nil))
;;;###autoload
(defun +haskell/evil-open-below ()
"Opens a line below the current mode"
(interactive)
(evil-append-line nil)
(haskell-indentation-newline-and-indent))

View File

@@ -3,19 +3,14 @@
(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
haskell-process-auto-import-loaded-modules t
haskell-process-show-overlays (not (featurep! :tools flycheck))) ; redundant with flycheck
haskell-process-show-overlays (not (featurep! :checkers syntax))) ; redundant with flycheck
(set-lookup-handlers! 'haskell-mode
:definition #'haskell-mode-jump-to-def-or-tag)
@@ -25,6 +20,8 @@
(set-repl-handler!
'(haskell-mode haskell-cabal-mode literate-haskell-mode)
#'+haskell/open-repl :persist t)
;; Don't kill REPL popup on ESC/C-g
(set-popup-rule! "^\\*haskell\\*" :quit nil)
(add-hook! 'haskell-mode-hook
#'haskell-collapse-mode ; support folding haskell code blocks
@@ -32,10 +29,24 @@
(add-to-list 'completion-ignored-extensions ".hi")
(map! :map haskell-mode-map
:n "o" #'+haskell/evil-open-below
:n "O" #'+haskell/evil-open-above
(:when (featurep! :tools lookup)
[remap haskell-mode-jump-to-def-or-tag] #'+lookup/definition))
(map! :localleader
:map haskell-mode-map
;; this is set to use cabal for dante users and stack for intero users:
"b" #'haskell-process-cabal-build
"c" #'haskell-cabal-visit-file
"h" #'haskell-hide-toggle
"H" #'haskell-hide-toggle-all))
;;
;;; Backends
(cond ((featurep! +dante) (load! "+dante"))
((or (featurep! +lsp)
(featurep! +ghcide))
(load! "+lsp")))

View File

@@ -7,12 +7,6 @@
(when (featurep! +dante)
(unless (executable-find "cabal")
(warn! "Couldn't find cabal, haskell-mode may have issues")))
(when (featurep! +intero)
(unless (executable-find "stack")
(warn! "Couldn't find stack. Intero will not work")))
(when (or (featurep! +dante) (featurep! +intero))
(warn! "Couldn't find cabal, haskell-mode may have issues"))
(unless (executable-find "hlint")
(warn! "Couldn't find hlint. Flycheck may have issues in haskell-mode")))

View File

@@ -1,12 +1,12 @@
;; -*- no-byte-compile: t; -*-
;;; lang/haskell/packages.el
(package! haskell-mode)
(package! haskell-mode :pin "41683c0e634bb3f54eac8747919a82132e1714fe")
(cond ((featurep! +dante)
(package! dante)
(package! attrap))
((featurep! +lsp)
(package! lsp-haskell))
((featurep! +intero) ; DEPRECATED
(package! intero)))
(when (featurep! +dante)
(package! dante :pin "7411904bfbde25cdb986e001ec682593dcb7c5e3")
(package! attrap :pin "4cf3e4a16255997e7c3c39682a72866a0a37dd4b"))
(when (or (and (featurep! +lsp)
(not (featurep! :tools lsp +eglot)))
(featurep! +ghcide))
(package! lsp-haskell :pin "17d7d4c6615b5e6c7442828720730bfeda644af8"))