hi guys
question for those who use emacs
how you make eglot restart after cabal file is changed. Every time when I need to change something in cabal I have to manually restart eglot
here is my config
(use-package eglot
:ensure t
:config
(add-hook 'haskell-mode-hook 'eglot-ensure)
(add-hook 'haskell-mode-hook 'company-mode)
(add-hook 'haskell-mode-hook 'turn-on-haskell-indentation)
(custom-set-variables
'(haskell-stylish-on-save t)
'(haskell-tags-on-save t)
'(haskell-process-suggest-remove-import-lines t)
'(haskell-process-auto-import-loaded-modules t)
'(haskell-process-log t))
(eval-after-load 'haskell-mode '(progn
(define-key haskell-mode-map (kbd "C-c C-l") 'haskell-process-load-or-reload)
(define-key haskell-mode-map (kbd "C-c C-z") 'haskell-interactive-switch)
(define-key haskell-mode-map (kbd "C-c C-o") 'haskell-compile)
(define-key haskell-mode-map (kbd "C-c v c") 'haskell-cabal-visit-file)))
:custom
(eglot-autoshutdown t) ;; shutdown language server after closing last file
(eglot-confirm-server-initiated-edits nil) ;; allow edits without confirmation
(eglot-send-changes-idle-time 0.1)
)
(let ((my-cabal-path (expand-file-name "~/.cabal/bin")))
(setenv "PATH" (concat my-cabal-path path-separator (getenv "PATH")))
(add-to-list 'exec-path my-cabal-path))
(add-hook 'after-save-hook 'my/eglot-reconnect-on-cabal-change)
(add-hook 'find-file-hook 'my/eglot-reconnect-on-cabal-change)
(defun my/eglot-reconnect-on-cabal-change ()
"Reconnect Eglot when a cabal file is changed."
(when (and (bound-and-true-p eglot--managed-mode) ;; Check if eglot is active
(string-match-p "\\.cabal\\'" buffer-file-name))
(message "Triggering eglot-reconnect for cabal file") ;; Debug message
(eglot-reconnect))) ;; Use eglot-reconnect instead of eglot-reload
I’ve asked chatGPT about it and she proposed to add extra hooks + function my/eglot-reconnect-on-cabal-change but it doesn’t work
how you make eglot restart after changing cabal?
please, help! it’s a pain to restart it manually every time
P.S I know that my config might have mistakes or something, so please, I need your help
OS: macOS
HSL: 2.7.0.0 (GHC: 9.2.8)