Skip to content

Instantly share code, notes, and snippets.

@Cmdv
Created November 8, 2020 16:12
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Cmdv/70d00515a1b9a7def257ee89344120c4 to your computer and use it in GitHub Desktop.
Save Cmdv/70d00515a1b9a7def257ee89344120c4 to your computer and use it in GitHub Desktop.
Emacs HLS setup
;;; $DOOMDIR/config.el -*- lexical-binding: t; -*-
;; Place your private configuration here! Remember, you do not need to run 'doom
;; sync' after modifying this file!
;; Some functionality uses this to identify you, e.g. GPG configuration, email
;; clients, file templates and snippets.
(setq user-full-name "John Doe"
user-mail-address "john@doe.com")
;; Doom exposes five (optional) variables for controlling fonts in Doom. Here
;; are the three important ones:
;;
;; + `doom-font'
;; + `doom-variable-pitch-font'
;; + `doom-big-font' -- used for `doom-big-font-mode'; use this for
;; presentations or streaming.
;;
;; They all accept either a font-spec, font string ("Input Mono-12"), or xlfd
;; font string. You generally only need these two:
(setq doom-font (font-spec :family "monospace" :size 14))
;; There are two ways to load a theme. Both assume the theme is installed and
;; available. You can either set `doom-theme' or manually load a theme with the
;; `load-theme' function. This is the default:
(setq doom-theme 'doom-one)
;; If you use `org' and don't want your org files in the default location below,
;; change `org-directory'. It must be set before org loads!
(setq org-directory "~/org/")
;;;;;;;;;;;;
;; direnv ;;
;;;;;;;;;;;;
(add-hook 'before-hack-local-variables-hook #'direnv-update-environment)
;; Autocompletion(company)
(setq company-idle-delay 0.5
company-minimum-prefix-length 2
;; company-show-numbers t
)
;; lsp-ui
(after! lsp-ui
(setq lsp-ui-doc-enable t
lsp-ui-doc-glance 1
lsp-ui-doc-delay 0.5
lsp-ui-doc-include-signature t
lsp-ui-doc-position 'Top
lsp-ui-doc-border "#fdf5b1"
lsp-ui-doc-max-width 65
lsp-ui-doc-max-height 70
lsp-ui-sideline-enable t
lsp-ui-sideline-ignore-duplicate t
lsp-ui-peek-enable t
lsp-ui-flycheck-enable -1)
(add-to-list 'lsp-ui-doc-frame-parameters '(left-fringe . 0))
)
;;;;;;;;;;;;;
;; haskell ;;
;;;;;;;;;;;;;
(map! :leader
(:after lsp-mode
(:prefix ("l" . "LSP")
:desc "Restart LSP server" "r" #'lsp-workspace-restart
:desc "Excute code action" "a" #'lsp-execute-code-action
:desc "Go to definition" "d" #'lsp-find-definition
:desc "Toggle doc mode" "d" #'lsp-ui-doc-mode
(:prefix ("u" . "LSP UI")
:desc "Toggle doc mode" "d" #'lsp-ui-doc-mode
:desc "Toggle sideline mode" "s" #'lsp-ui-sideline-mode
:desc "Glance at doc" "g" #'lsp-ui-doc-glance
:desc "Toggle imenu" "i" #'lsp-ui-imenu
)
)))
;; (use-package lsp-haskell
;; :ensure t
;; :config
;; (setq lsp-haskell-process-path-hie "haskell-language-server-wrapper")
;; (setq lsp-haskell-process-args-hie '("-d"))
;; ;; Comment/uncomment this line to see interactions between lsp client/server.
;; ;; (setq lsp-log-io t)
;; )
;; (after! lsp-haskell
;; (setq lsp-haskell-process-path-hie "haskell-language-server-wrapper")
;; )
;; (after! flycheck
;; (pushnew! flycheck-disabled-checkers 'haskell-ghc 'haskell-stack-ghc))
;; ;; (after! lsp-haskell
;; (setq warning-minimum-level ':error) ; This is temporary for a bug in lsp-ui that pops up errors
;; (lsp-haskell-set-hlint-on)
;; (lsp-haskell-set-liquid-on)
;; )
;; (after! flycheck
;; (pushnew! flycheck-disabled-checkers 'haskell-ghc 'haskell-stack-ghc))
;; (setq haskell-interactive-popup-errors nil)
;; (use-package ormolu
;; :hook (haskell-mode . ormolu-format-on-save-mode)
;; :bind
;; (:map haskell-mode-map
;; ("C-c r" . ormolu-format-buffer)
;; )
;; )
;;;;;;;;;;;;;;;;
;; PureScript ;;
;;;;;;;;;;;;;;;;
(use-package! psc-ide
:hook (purescript-mode . psc-ide-mode)
:config
(remove-hook 'company-backends 'company-psc-ide-backend)
(set-company-backend! 'purescript-mode 'company-psc-ide-backend))
;; This determines the style of line numbers in effect. If set to `nil', line
;; numbers are disabled. For relative line numbers, set this to `relative'.
(setq display-line-numbers-type t)
(setq-default show-trailing-whitespace t)
(setq-default indicate-empty-lines t)
;; Here are some additional functions/macros that could help you configure Doom:
;;
;; - `load!' for loading external *.el files relative to this one
;; - `use-package' for configuring packages
;; - `after!' for running code after a package has loaded
;; - `add-load-path!' for adding directories to the `load-path', relative to
;; this file. Emacs searches the `load-path' when you load packages with
;; `require' or `use-package'.
;; - `map!' for binding new keys
;;
;; To get information about any of these functions/macros, move the cursor over
;; the highlighted symbol at press 'K' (non-evil users must press 'C-c g k').
;; This will open documentation for it, including demos of how they are used.
;;
;; You can also try 'gd' (or 'C-c g d') to jump to their definition and see how
;; they are implemented.
@Cmdv
Copy link
Author

Cmdv commented Nov 11, 2020

is it normal to need to build haskell-language-server before each session in every project (for emacs)?

tintinthong 1 day ago
is there like a hook or some cache. I dont really know how this works.

cmdv 1 day ago
it should only be per ghc version as far as I know

chrispenner 1 day ago
Do you have it installed in your path somewhere, or is your tooling installing it for you each time?
If you install it globally yourself it shouldn’t need to do that.

chrispenner 1 day ago
You might need to install one version for each GHC, that’s what haskell-language-server-wrapper helps with

chrispenner 1 day ago
In general, if you use stack, you can also use stack build --copy-compiler-tool to compile something against a given LTS and make it available in any other project on the same LTS, you just have to then run it with stack exec --

chrispenner 1 day ago
copy-compiler-tool is a bit unfortunately named 🙃

tintinthong 1 day ago
Do you have it installed in your path somewhere, or is your tooling installing it for you each time?
It is defo in my path. I cloned the repo and built it using stack using these instructions -- should be globally https://github.com/haskell/haskell-language-server#using-haskell-language-server-with-emacs
I am using doom emacs (and I thought adding lsp flag to haskell would work) but I think I am missing some features. Particularly, it says here that I need lsp-mode lsp-ui lsp-haskell I cant find lsp-haskell (edited)

tintinthong 1 day ago
right. so i didn realise that this is literally a server that you must run with the --lsp flag

@Raagh
Copy link

Raagh commented Aug 13, 2021

is this your final config for purescript? I am trying to get psc-ide-emacs to work but it seems it can't find the purs.bin executable.

@Cmdv
Copy link
Author

Cmdv commented Aug 13, 2021

@Raagh yeah that's how I have it now. But you need to make sure you have purs on your $PATH from memory it struggles when it's only install locally to the project (so try installing purescript globally)! also with doom-emacs I make sure to run doom sync to make sure all my paths are up to date.

@Raagh
Copy link

Raagh commented Aug 14, 2021

Thanks for answering. yeah after installing it globally it works fine. I couldn't make it work locally.

@Cmdv
Copy link
Author

Cmdv commented Aug 14, 2021

cool, glad you got it working 😄

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