From 24c0d3565d8e7aedc636fbdcf3df93b0c727afcc Mon Sep 17 00:00:00 2001 From: jao Date: Thu, 6 Oct 2022 06:24:10 +0100 Subject: more comfortable haskell without lsp/eglot --- attic/elisp/misc.el | 4 ++++ init.el | 55 +++++++++++++++++++++++++++++++++++++++++++---------- 2 files changed, 49 insertions(+), 10 deletions(-) diff --git a/attic/elisp/misc.el b/attic/elisp/misc.el index fec2c41..4b47104 100644 --- a/attic/elisp/misc.el +++ b/attic/elisp/misc.el @@ -414,6 +414,10 @@ (interactive) (jao-notify "Volume" (format "%s%%" (jao-player-volume)))) +;;;; eglot +(use-package eglot + :ensure t + :bind (:map eglot-mode-map (("C-h ." . jao-eldoc-toggle)))) ;;; corfu (use-package corfu :ensure t diff --git a/init.el b/init.el index c34af8f..afac20a 100644 --- a/init.el +++ b/init.el @@ -406,7 +406,7 @@ :init (setq eldoc-minor-mode-string nil eldoc-idle-delay 0.1 eldoc-echo-area-display-truncation-message nil - eldoc-echo-area-use-multiline-p 1 + eldoc-echo-area-use-multiline-p 5 eldoc-echo-area-prefer-doc-buffer 'maybe eldoc-display-functions '(eldoc-display-in-echo-area)) :config (global-eldoc-mode 1)) @@ -2008,11 +2008,6 @@ :bind (:map flymake-mode-map (("M-m" . jao-transient-flymake)))) -;;;; eglot -(use-package eglot - :ensure t - :bind (:map eglot-mode-map (("C-h ." . jao-eldoc-toggle)))) - ;;;; workarounds (setq c-type-finder-time-slot nil) @@ -2229,14 +2224,34 @@ (haskell-completing-read-function 'completing-read) (haskell-font-lock-symbols nil) (haskell-hoogle-command "hoogle") - (haskell-interactive-popup-errors nil) + (haskell-interactive-popup-errors t) (haskell-process-auto-import-loaded-modules t) (haskell-process-log t) (haskell-process-suggest-remove-import-lines t) (haskell-process-suggest-hoogle-imports t) (haskell-process-type 'cabal-repl) (haskell-process-use-presentation-mode t) - (haskell-stylish-on-save nil)) + (haskell-stylish-on-save nil) + (haskell-tags-on-save t)) + + :init + ;; For use with M-x align + (add-to-list 'align-rules-list + '(haskell-types + (regexp . "\\(\\s-+\\)\\(::\\|∷\\)\\s-+") + (modes quote (haskell-mode haskell-literate-mode)))) + (add-to-list 'align-rules-list + '(haskell-assignment + (regexp . "\\(\\s-+\\)=\\s-+") + (modes quote (haskell-mode haskell-literate-mode)))) + (add-to-list 'align-rules-list + '(haskell-arrows + (regexp . "\\(\\s-+\\)\\(->\\|→\\)\\s-+") + (modes quote (haskell-mode haskell-literate-mode)))) + (add-to-list 'align-rules-list + '(haskell-left-arrows + (regexp . "\\(\\s-+\\)\\(<-\\|←\\)\\s-+") + (modes quote (haskell-mode haskell-literate-mode)))) :config (defun jao-haskell-hoogle (no-info) @@ -2247,7 +2262,22 @@ 'safe-local-variable (apply-partially #'seq-every-p #'stringp)) - (dolist (h '(haskell-decl-scan-mode + (defun jao-haskell-eldoc (cb) + (let ((msg (or (haskell-doc-current-info--interaction t) + (haskell-doc-sym-doc (haskell-ident-at-point)) + ""))) + (funcall cb (replace-regexp-in-string "[\n ]+" " " msg)))) + + (setq tags-revert-without-query t) + + (defun jao-haskell-mode () + (require 'haskell-doc) + (setq-local eldoc-documentation-function 'eldoc-documentation-default + eldoc-documentation-functions '(jao-haskell-eldoc)) + (eldoc-mode)) + + (dolist (h '(jao-haskell-mode + haskell-decl-scan-mode haskell-indentation-mode interactive-haskell-mode)) (add-hook 'haskell-mode-hook h)) @@ -2256,7 +2286,9 @@ :bind (:map haskell-mode-map (("C-c C-d" . jao-haskell-hoogle) + ("C-c C-s" . haskell-session-change-target) ("C-c h" . haskell-hoogle) + ("C-c t" . haskell-doc-show-type) ("C-c C-e" . haskell-command-insert-language-pragma) ("C-M-n" . flymake-goto-next-error) ("C-M-p" . flymake-goto-prev-error) @@ -2292,10 +2324,13 @@ ("if" "Format imports" haskell-mode-format-imports) ("is" "Sort imports" haskell-sort-imports) ("ia" "Align imports" haskell-align-imports)] + ["Session" + ("s" "Change the session's target" haskell-session-change-target)] ["Code" ("e" "insert language pragma" haskell-command-insert-language-pragma) ("v" "visit cabal file" haskell-cabal-visit-file) - ("h" "Hoogle" jao-haskell-hoogle)] + ("h" "hoogle" jao-haskell-hoogle) + ("t" "show type" haskell-doc-show-type)] ["Flymake" ("n" "next error" flymake-goto-next-error) ("p" "previous error" flymake-goto-prev-error)]) -- cgit v1.2.3