yeet
This commit is contained in:
73
.config/emacs/modules/lang/haskell/README.org
Normal file
73
.config/emacs/modules/lang/haskell/README.org
Normal file
@@ -0,0 +1,73 @@
|
||||
#+TITLE: lang/haskell
|
||||
#+DATE: January 16, 2017
|
||||
#+SINCE: v0.7
|
||||
#+STARTUP: inlineimages
|
||||
|
||||
* Table of Contents :TOC:
|
||||
- [[#description][Description]]
|
||||
- [[#maintainers][Maintainers]]
|
||||
- [[#module-flags][Module Flags]]
|
||||
- [[#plugins][Plugins]]
|
||||
- [[#prerequisites][Prerequisites]]
|
||||
- [[#features][Features]]
|
||||
- [[#configuration][Configuration]]
|
||||
|
||||
* Description
|
||||
Adds Haskell support to Doom Emacs.
|
||||
|
||||
** Maintainers
|
||||
This module has no dedicated maintainers.
|
||||
|
||||
** Module Flags
|
||||
+ =+lsp= Enable LSP support with for [[https://github.com/haskell/haskell-language-server][haskell-language-server]] (requires the =:tools lsp= module).
|
||||
|
||||
** Plugins
|
||||
+ [[https://github.com/haskell/haskell-mode][haskell-mode]]
|
||||
+ [[https://github.com/emacs-lsp/lsp-haskell][lsp-haskell]] (=+lsp=, =:tools lsp=)
|
||||
|
||||
* Prerequisites
|
||||
It is recommended to install the haskell tooling using [[https://www.haskell.org/ghcup/][ghcup]]. Only ghc is needed
|
||||
for basic functionality:
|
||||
|
||||
#+BEGIN_SRC bash
|
||||
ghcup install ghc
|
||||
#+END_SRC
|
||||
|
||||
but =+lsp= users should also install the language server:
|
||||
|
||||
#+BEGIN_SRC bash
|
||||
ghcup install hls
|
||||
#+END_SRC
|
||||
|
||||
Installing [[https://www.haskell.org/cabal/][cabal]] or [[https://docs.haskellstack.org/en/stable/README/][stack]] as well is recommended, and can be done through
|
||||
=ghcup=.
|
||||
|
||||
=haskell-mode= provides support for [[https://github.com/ndmitchell/hoogle][hoogle]], which can be installed through
|
||||
system package manager, cabal, or stack.
|
||||
|
||||
=haskell-language-server= provides support for [[https://github.com/ndmitchell/hlint/][hlint]], and haskell code
|
||||
formatters such as [[https://github.com/lspitzner/brittany][brittany]], [[https://github.com/ennocramer/floskell][floskell]], [[https://github.com/tweag/ormolu][ormolu]], [[https://github.com/fourmolu/fourmolu][fourmolu]], and [[https://github.com/haskell/stylish-haskell][stylish-haskell]],
|
||||
which can be installed through system package manager, cabal, or stack.
|
||||
|
||||
* Features
|
||||
This module intergrates the haskell packages into Doom by providing things such
|
||||
as repl support, project root recognition, etc. It also provide the following
|
||||
keybindings:
|
||||
|
||||
| Keybinding | Description |
|
||||
|-------------------+-----------------------------------------------|
|
||||
| =<localleader> b= | Build the current cabal project |
|
||||
| =<localleader> c= | Visit the =.cabal= file of the current buffer |
|
||||
| =<localleader> h= | Toggle visibility of the form at point |
|
||||
| =<localleader> H= | hides all top level functions |
|
||||
|
||||
* Configuration
|
||||
After installing your preferred formatter, make sure to set
|
||||
=lsp-haskell-formatting-provider= to it.
|
||||
|
||||
Make sure to configure the lsp to use your perfered formatter, e.g.:
|
||||
#+BEGIN_SRC elisp
|
||||
;; ~/.doom.d/config.el
|
||||
(after!
|
||||
(setq lsp-haskell-formatting-provider "brittany"))
|
||||
#+END_SRC
|
||||
28
.config/emacs/modules/lang/haskell/autoload.el
Normal file
28
.config/emacs/modules/lang/haskell/autoload.el
Normal file
@@ -0,0 +1,28 @@
|
||||
;;; lang/haskell/autoload.el -*- lexical-binding: t; -*-
|
||||
|
||||
;;;###autoload
|
||||
(defun +haskell/open-repl (&optional arg)
|
||||
"Opens a Haskell REPL."
|
||||
(interactive "P")
|
||||
(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-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))
|
||||
52
.config/emacs/modules/lang/haskell/config.el
Normal file
52
.config/emacs/modules/lang/haskell/config.el
Normal file
@@ -0,0 +1,52 @@
|
||||
;;; lang/haskell/config.el -*- lexical-binding: t; -*-
|
||||
|
||||
(after! projectile
|
||||
(add-to-list 'projectile-project-root-files "stack.yaml"))
|
||||
|
||||
|
||||
;;
|
||||
;;; 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! :checkers syntax))) ; redundant with flycheck
|
||||
|
||||
(set-lookup-handlers! 'haskell-mode
|
||||
:definition #'haskell-mode-jump-to-def-or-tag)
|
||||
(set-file-template! 'haskell-mode
|
||||
:trigger #'haskell-auto-insert-module-template
|
||||
:project t)
|
||||
(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
|
||||
#'interactive-haskell-mode)
|
||||
|
||||
(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
|
||||
"b" #'haskell-process-cabal-build
|
||||
"c" #'haskell-cabal-visit-file
|
||||
"h" #'haskell-hide-toggle
|
||||
"H" #'haskell-hide-toggle-all))
|
||||
|
||||
|
||||
(use-package! lsp-haskell
|
||||
:when (featurep! +lsp)
|
||||
:after lsp-mode
|
||||
:preface (add-hook 'haskell-mode-local-vars-hook #'lsp!)
|
||||
:config
|
||||
;; Does some strange indentation if it pastes in the snippet
|
||||
(setq-hook! 'haskell-mode-hook yas-indent-line 'fixed))
|
||||
26
.config/emacs/modules/lang/haskell/doctor.el
Normal file
26
.config/emacs/modules/lang/haskell/doctor.el
Normal file
@@ -0,0 +1,26 @@
|
||||
;; -*- lexical-binding: t; no-byte-compile: t; -*-
|
||||
;;; lang/haskell/doctor.el
|
||||
|
||||
(assert! (or (not (featurep! +lsp))
|
||||
(featurep! :tools lsp))
|
||||
"This module requires (:tools lsp)")
|
||||
|
||||
(unless (executable-find "cabal")
|
||||
(warn! "Couldn't find cabal. haskell-mode may have issues."))
|
||||
|
||||
(unless (executable-find "hoogle")
|
||||
(warn! "Couldn't find hoogle. Documentation searching will not work."))
|
||||
|
||||
(unless (or (featurep! +lsp)
|
||||
(executable-find "hlint"))
|
||||
(warn! "Couldn't find hlint. Flycheck may have issues in haskell-mode.
|
||||
Install it or enable +lsp."))
|
||||
|
||||
(when (and (featurep! :editor format)
|
||||
(not (executable-find "brittany")))
|
||||
(warn! "Couldn't find brittany. Code formatting will not work.
|
||||
Install it or enable +lsp."))
|
||||
|
||||
(when (and (featurep! +lsp)
|
||||
(not (executable-find "haskell-language-server-wrapper")))
|
||||
(warn! "Couldn't find haskell-language-server."))
|
||||
8
.config/emacs/modules/lang/haskell/packages.el
Normal file
8
.config/emacs/modules/lang/haskell/packages.el
Normal file
@@ -0,0 +1,8 @@
|
||||
;; -*- no-byte-compile: t; -*-
|
||||
;;; lang/haskell/packages.el
|
||||
|
||||
(package! haskell-mode :pin "8402caa341d90b4236f5c0a802751f9023ccfbe7")
|
||||
|
||||
(when (and (featurep! +lsp)
|
||||
(not (featurep! :tools lsp +eglot)))
|
||||
(package! lsp-haskell :pin "4e62cf897dd9e9fcef25c6e8e483490a07a5d439"))
|
||||
Reference in New Issue
Block a user