Skip to content

Instantly share code, notes, and snippets.

@ecthiender
Last active June 7, 2024 04:28
Show Gist options
  • Save ecthiender/b9db474e80113bdc18d472de1593eb3c to your computer and use it in GitHub Desktop.
Save ecthiender/b9db474e80113bdc18d472de1593eb3c to your computer and use it in GitHub Desktop.
Step by step instructions to setup doom emacs for Haskell + Haskell Language Server (LSP)

Install doom emacs

git clone --depth 1 https://github.com/hlissner/doom-emacs ~/.emacs.d
cd ~/.emacs.d
bin/doom install

Optional

You can backup your existing ~/.emacs.d, if you have one. If you want to revert back to your older emacs setup, just copy the backup back into ~/.emacs.d and restart emacs

Setup for Haskell dev

Install HLS

Install haskell-language-server, which is the lsp implementation for haskell, using ghcup.

ghcup install hls 0.8.0

Add config to enable Haskell + LSP

To enable haskell, in ~/.doom.d/packages.el add these line:

(package! haskell-mode)
(package! lsp-haskell)

And then in ~/.doom.d/init.el,

  • under :tools, add lsp
  • under :lang, add (haskell +lsp)

Then run:

cd ~/.emacs.d
bin/doom sync

Optional stylish-haskell

To configure to run stylish-haskell on save, add this to ~/.doom.d/config.el -

(setq haskell-stylish-on-save t)

Finally, restart your emacs for the changes to be applied.

@0xadeeb
Copy link

0xadeeb commented Jan 8, 2022

Me after doing all of these ran into Command "haskell-language-server-wrapper --lsp -d -l /tmp/hls.log" is not present on the path. in lsp-log.

@isqnwtn
Copy link

isqnwtn commented Jun 21, 2022

add the exec path to emacs by adding

(setenv "PATH" (concat (getenv "PATH") ":/path/to/hls/containing/bin"))
(setq exec-path (append exec-path '("/path/to/hls/containing/bin")))

to config.el

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment