This is a ghcid minor mode support for emacs. It uses a terminal with compilation-mode.
This minor mode will provide following features when activated:
- start ghcid automatically once activated
- detect the project root directory based on open buffer file
- check project build tools and construct the ghcid command accordingly
- jump to error position
- customize the ghcid repl command, test command, setup command or lint command
With doom emacs, add following to packages.el
:
(package! ghcid
:recipe (:host github :repo "hughjfchen/ghcid-mode"))
and following to the config.el
:
(use-package! ghcid
:config (load! ghcid))
For vallina emacs, recommand use use-package
:
install it:
(straight-use-package '(ghcid-mode :host github :repo "hughjfchen/ghcid-mode"
:files (:defaults "*.el")))
and then config to activate it when haskell-mode is active:
(use-package haskell-mode
:init
(add-hook 'haskell-mode-hook #'ghcid-mode))
If ghcid-mode not able to start ghcid with correct command, you can config it using a .dir-locals.el
file as so:
((haskell-mode . ((ghcid-repl-command-line . ("cabal" "new-repl" "hsprjup:lib:hsprjup" "\\-f" "ghcidlibwithtest"))
(ghcid-test-command-line . "TestMain.main")
(ghcid-setup-command-line . ":load test/Spec.hs"))))
Following table lists the customization variables:
name | type | meaning | remarks |
---|---|---|---|
ghcid-project-root | string | the project root directory | usually no need to set it, ghcid-mode should detect it automatically |
ghcid-target | string | the ghci repl target, could be a lib, an exe or a test | For multi target you could set |
ghcid-repl-command-line | a list with string | the ghcid command line to start the ghci | the whole command to start the ghci |
ghcid-test-command-line | string | the ghcid test command | |
ghcid-setup-command-line | string | the ghcid setup command | |
ghcid-lint-command-line | string | the ghcid lint command |
This mode uses compilation-mode
within a terminal, so if there’re some build errors, you can use the flycheck
keys(usually ]+q
and [+q
) to jump to the errors.
This minor mode is based on the work of the original ghcid
plugin for emacs and inspired by the excellent dante project.
So Credits go to Following people:
- Matthew Wraith wraithm@gmail.com
- Yorick Sijsling
- Vasiliy Yorkin vasiliy.yorkin@gmail.com
- Neil Mitchell ndmitchell@gmail.com
- Jean-Philippe Bernardy