fix(gs/emacs): Ensure we run hls from the right dir

Xanthous specifically breaks pretty majestically if it's built from
anything but a source dir, due to the TH splices we're doing to embed
messages.yaml files - this does some extra shuffling to make sure we
always cd to the project directory when running haskell-language-server

Change-Id: I6daee712f04b96d5755dcbc3dbad4c7b78a46f61
Reviewed-on: https://cl.tvl.fyi/c/depot/+/905
Reviewed-by: BuildkiteCI
Reviewed-by: glittershark <grfn@gws.fyi>
Tested-by: BuildkiteCI
This commit is contained in:
Griffin Smith 2020-07-03 17:38:40 -04:00 committed by glittershark
parent 6480a81c16
commit ca03175e31

View file

@ -717,6 +717,26 @@
(message "disabled flymake-mode"))) (message "disabled flymake-mode")))
(advice-add #'flymake-mode :around #'never-flymake-mode) (advice-add #'flymake-mode :around #'never-flymake-mode)
(defun +grfn/wrap-lsp-haskell-process (argv)
(let* ((project-dir (locate-dominating-file
(buffer-file-name)
"hie.yaml"))
(shell-dot-nix (expand-file-name "shell.nix" project-dir)))
;; (when (string-equal default-directory "/home/grfn/code/depot")
;; (debug))
(message "%s %s %s %s"
(buffer-file-name)
default-directory
project-dir
shell-dot-nix)
(if (file-exists-p shell-dot-nix)
`("bash" "-c"
,(format "cd %s && nix-shell %s --run '%s'"
project-dir
shell-dot-nix
(s-join " " argv)))
argv)))
(use-package! lsp-haskell (use-package! lsp-haskell
:after (lsp-mode lsp-ui haskell-mode) :after (lsp-mode lsp-ui haskell-mode)
;; :hook ;; :hook
@ -724,7 +744,9 @@
:config :config
(setq lsp-haskell-process-path-hie "haskell-language-server-wrapper" (setq lsp-haskell-process-path-hie "haskell-language-server-wrapper"
lsp-haskell-process-args-hie lsp-haskell-process-args-hie
'("-d" "-l" "/tmp/hie.log" "+RTS" "-M4G" "-H1G" "-K4G" "-A16M" "-RTS")) '("-d" "-l" "/tmp/hie.log" "+RTS" "-M4G" "-H1G" "-K4G" "-A16M" "-RTS")
lsp-haskell-process-wrapper-function
#'+grfn/wrap-lsp-haskell-process)
(add-hook 'haskell-mode-hook #'+grfn/haskell-mode-setup 't)) (add-hook 'haskell-mode-hook #'+grfn/haskell-mode-setup 't))
(use-package! lsp-imenu (use-package! lsp-imenu