Skip to content

Instantly share code, notes, and snippets.

@ecthiender
Last active October 25, 2023 05:33
Show Gist options
  • Star 18 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • 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.

@jlrpnbbngtn
Copy link

jlrpnbbngtn commented Aug 2, 2021

This is great. Thank you!

@anka-213
Copy link

anka-213 commented Aug 6, 2021

Are these really needed?

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

I thought it was implied by

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

@ecthiender
Copy link
Author

Are these really needed?

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

I thought it was implied by

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

@anka-213 IIRC, yes. But I might be completely wrong. I don't remember if I faced any other issues, that I included those packages explicitly. But I guess you can try out without including the packages and see if it works.

@anka-213
Copy link

anka-213 commented Aug 6, 2021

I did have issues when just doing the later part. After doing both and running doom upgrade it magically worked despite nothing else we tried working, so you are probably right.

The instructions on the hls README might need to be updated to include this as well.

@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