about summary refs log tree commit diff
path: root/users/glittershark
diff options
context:
space:
mode:
authorGriffin Smith <grfn@gws.fyi>2020-07-03T21·38-0400
committerglittershark <grfn@gws.fyi>2020-07-03T23·23+0000
commitca03175e3177578c6b352236ac52851200d6f00c (patch)
tree71ce9e8577d8eccc5da82732e09cde6f37a09d1f /users/glittershark
parent6480a81c1662f75e1996aeb3cb114baf53ca09b9 (diff)
fix(gs/emacs): Ensure we run hls from the right dir r/1205
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
Diffstat (limited to 'users/glittershark')
-rw-r--r--users/glittershark/emacs.d/config.el24
1 files changed, 23 insertions, 1 deletions
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