Created
June 16, 2016 08:54
-
-
Save unhammer/edd926fff70af71d1c77ed73461d55a9 to your computer and use it in GitHub Desktop.
some emacs haskell configs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(use-package evil-leader | |
;; needs to be enabled before M-x evil-mode! | |
:ensure t | |
:config | |
(evil-leader/set-leader ",") | |
(evil-leader/set-key-for-mode #'haskell-mode | |
"t" #'intero-type-at ; was: haskell-mode-show-type-at | |
"T" #'intero-info ; was: haskell-doc-show-type | |
"I" #'haskell-do-info | |
"g" #'intero-goto-definition | |
"r" #'haskell-process-load-file | |
"z" #'haskell-interactive-switch | |
"þ" #'haskell-process-do-type) | |
(evil-leader-mode 1) | |
(global-evil-leader-mode 1)) | |
(evil-define-key 'normal haskell-mode-map (kbd "=") #'indent-for-tab-command) | |
(use-package intero | |
:ensure t | |
:defer t | |
:init | |
(add-hook 'haskell-mode-hook #'intero-mode)) | |
(use-package haskell-mode | |
:defer t | |
:init | |
(add-hook 'haskell-mode-hook #'haskell-doc-mode) | |
(add-hook 'haskell-mode-hook #'haskell-decl-scan-mode) | |
(setq haskell-process-suggest-add-package nil | |
haskell-ask-also-kill-buffers nil | |
haskell-stylish-on-save t | |
haskell-process-auto-import-loaded-modules t | |
haskell-process-log t | |
haskell-interactive-popup-errors nil) | |
(add-hook 'haskell-mode-hook (lambda () (whitespace-toggle-options 'tabs))) | |
(add-to-list 'exec-path (~ "/.emacs.d/haskell/.cabal-sandbox/bin")) | |
:config | |
(define-key haskell-mode-map (kbd "M-,") #'pop-tag-mark) | |
(define-key haskell-mode-map (kbd "C-,") #'haskell-move-nested-left) | |
(define-key haskell-mode-map (kbd "C-.") #'haskell-move-nested-right) | |
(define-key haskell-mode-map (kbd "M-RET") (defun haskell-mode-open-line (n-todo) | |
(interactive "P") | |
(insert "\n") | |
(backward-char))) | |
(define-key haskell-mode-map (kbd "C-c C-c") #'haskell-compile) | |
(define-key haskell-mode-map (kbd "C-c C-z") #'haskell-interactive-switch) | |
(define-key haskell-mode-map (kbd "C-c t") #'haskell-mode-show-type-at) | |
(define-key haskell-mode-map (kbd "C-c v c") #'haskell-cabal-visit-file) | |
(define-key haskell-mode-map (kbd "C-c <") #'haskell-move-nested-left) | |
(define-key haskell-mode-map (kbd "C-c >") #'haskell-move-nested-right) | |
(defun haskell-do-info (&optional cPos cEnd) | |
"Bring up REPL and do :info on symbol at poinnt. | |
If interactive and region active or CPOS and CEND are non-nil, use that region." | |
(interactive "r") | |
(let ((symbol (if (and (and cPos cEnd) | |
(or (region-active-p) | |
(not (called-interactively-p 'interactive)))) | |
(buffer-substring-no-properties cPos cEnd) | |
(thing-at-point 'symbol)))) | |
(haskell-interactive-switch) | |
(haskell-interactive-mode-run-expr (format ":info %s" symbol))) | |
(goto-char (point-max)) | |
(haskell-interactive-switch-back))) | |
(use-package haskell-hoogle | |
:defer t | |
:init | |
(defun let-browse-url-firefox (orig-fun &rest args) | |
(let ((browse-url-browser-function #'browse-url-firefox)) | |
(apply orig-fun args))) | |
(advice-add #'hoogle :around #'let-browse-url-firefox) | |
(defun hoogle-firefox () | |
(interactive) | |
(let (haskell-hoogle-command) | |
(call-interactively #'hoogle)))) | |
(use-package haskell-doc | |
:defer t | |
:init | |
(defun haskell-doc-show-type-unless-showing (orig-fun &rest args) | |
(when (not (memq last-command '(haskell-mode-show-type-at | |
intero-type-at | |
haskell-process-do-type))) | |
(apply orig-fun args))) | |
(advice-add #'haskell-doc-mode-print-current-symbol-info | |
:around #'haskell-doc-show-type-unless-showing)) | |
(use-package hindent | |
:defer t | |
:init | |
(when (locate-library "hindent") | |
(add-hook 'haskell-mode-hook #'hindent-mode)) | |
(setq hindent-style "gibiansky")) | |
(use-package company-ghci | |
:ensure t | |
:after haskell | |
:config | |
(push '(company-ghci :with company-yasnippet :with company-dabbrev) company-backends)) | |
;; Smartparens: | |
(add-hook 'smartparens-mode-hook | |
(lambda () | |
(add-to-list 'sp-no-reindent-after-kill-modes #'haskell-mode) | |
(require 'smartparens-haskell) ; should add {-# #-} | |
(sp-local-pair 'haskell-mode "'" nil :actions nil) | |
(sp-local-pair 'haskell-mode "\\(" nil :actions nil) | |
(sp-local-pair 'interactive-haskell-mode "\\(" nil :actions nil) | |
(sp-local-pair 'minibuffer-inactive-mode "'" nil :actions nil))) | |
(defun no-indent-line-function-in-haskell (orig-fun &rest args) | |
(let ((indent-region-function (if (eq major-mode 'haskell-mode) | |
(lambda (_ __)) | |
indent-region-function)) | |
(indent-line-function (if (eq major-mode 'haskell-mode) | |
(lambda ()) | |
indent-line-function))) | |
(apply orig-fun args))) | |
(advice-add #'evil-sp-change :around #'no-indent-line-function-in-haskell) | |
(advice-add #'evil-sp-delete :around #'no-indent-line-function-in-haskell) | |
(advice-add #'evil-sp-delete-line :around #'no-indent-line-function-in-haskell) | |
(advice-add #'sp-kill-word :around #'no-indent-line-function-in-haskell) | |
(advice-add #'sp-forward-slurp-sexp :around #'no-indent-line-function-in-haskell) | |
(advice-add #'sp--indent-region :around #'no-indent-line-function-in-haskell) |
Glad it helped 😃 The rest of this gist is quite outdated though, I mostly just use lsp now
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think the Smartparens config fixes this issue -- thanks! haskell/haskell-mode#796