From ca03175e3177578c6b352236ac52851200d6f00c Mon Sep 17 00:00:00 2001 From: Griffin Smith Date: Fri, 3 Jul 2020 17:38:40 -0400 Subject: 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 Tested-by: BuildkiteCI --- users/glittershark/emacs.d/config.el | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/users/glittershark/emacs.d/config.el b/users/glittershark/emacs.d/config.el index a0120824fbe3..1a58325fc1c5 100644 --- a/users/glittershark/emacs.d/config.el +++ b/users/glittershark/emacs.d/config.el @@ -717,6 +717,26 @@ (message "disabled 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 :after (lsp-mode lsp-ui haskell-mode) ;; :hook @@ -724,7 +744,9 @@ :config (setq lsp-haskell-process-path-hie "haskell-language-server-wrapper" 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)) (use-package! lsp-imenu -- cgit 1.4.1