Created
January 1, 2015 15:15
-
-
Save wfaler/7c6d69d5363d01174ea1 to your computer and use it in GitHub Desktop.
Auto-setup of Haskell with syntax checking and completion. Requires following cabal packages: happy, alex, ghc-mod. Put this file in ~/.emacs.d/init.el
This file contains hidden or 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
(require 'package) | |
(setq package-list '(markdown-mode | |
yaml-mode | |
js2-mode | |
find-file-in-project | |
auto-complete | |
ghc | |
haskell-mode | |
flycheck | |
flycheck-haskell | |
)) | |
(add-to-list 'package-archives | |
'("melpa" . "http://melpa.org/packages/") t) | |
;; activate all the packages (in particular autoloads) | |
(package-initialize) | |
;; fetch the list of packages available | |
(unless package-archive-contents | |
(package-refresh-contents)) | |
;; install the missing packages | |
(dolist (package package-list) | |
(unless (package-installed-p package) | |
(package-install package))) | |
(when (not package-archive-contents) | |
(package-refresh-contents)) | |
;; NO FRILLS | |
(dolist (mode '(menu-bar-mode tool-bar-mode scroll-bar-mode)) | |
(when (fboundp mode) (funcall mode -1))) | |
(setq inhibit-startup-screen t) | |
;; NO JUNK | |
(setq auto-save-file-name-transforms `((".*" ,temporary-file-directory t)) | |
backup-directory-alist `((".*" . ,temporary-file-directory))) | |
;; HASKELL | |
(require 'auto-complete) | |
(require 'auto-complete-config) | |
(ac-config-default) | |
(add-hook 'flycheck-mode-hook 'flycheck-haskell-setup) | |
(autoload 'ghc-init "ghc" nil t) | |
(defun el-get-ghc-mod-hook () | |
(ghc-init) | |
(flycheck-mode)) | |
(add-hook 'haskell-mode-hook 'el-get-ghc-mod-hook) | |
(add-hook 'haskell-mode-hook 'turn-on-haskell-doc-mode) | |
(add-hook 'haskell-mode-hook 'turn-on-haskell-indentation) | |
(setq haskell-process-type 'cabal-repl | |
haskell-process-args-cabal-repl '("--ghc-option=-ferror-spans")) | |
(define-key haskell-mode-map (kbd "C-x C-d") nil) | |
(define-key haskell-mode-map (kbd "C-c C-z") 'haskell-interactive-switch) | |
(define-key haskell-mode-map (kbd "C-c C-l") 'haskell-process-load-file) | |
(define-key haskell-mode-map (kbd "C-c C-b") 'haskell-interactive-switch) | |
(define-key haskell-mode-map (kbd "C-c C-t") 'haskell-process-do-type) | |
(define-key haskell-mode-map (kbd "C-c C-i") 'haskell-process-do-info) | |
(define-key haskell-mode-map (kbd "C-c M-.") nil) | |
(define-key haskell-mode-map (kbd "C-c C-d") nil) | |
(define-key haskell-mode-map (kbd "C-c v c") 'haskell-cabal-visit-file) | |
;; auto-complete | |
(ac-define-source haskell | |
'((candidates | |
. (lambda () | |
(let ((resp (haskell-process-get-repl-completions (haskell-process) ac-prefix))) | |
(if (string= (car resp) "") | |
(cdr resp) | |
(mapcar (lambda (s) (car resp)) (cdr resp)))))))) | |
(add-hook 'haskell-mode-hook '(lambda () | |
(add-to-list 'ac-sources 'ac-source-haskell))) | |
;; END HASKELL | |
(column-number-mode) | |
(setq-default indent-tabs-mode nil) | |
(define-key global-map (kbd "RET") 'newline-and-indent) | |
;;(load-theme 'solarized-dark t) | |
(require 'js2-mode) | |
(add-to-list 'auto-mode-alist '("\\.js$" . js2-mode)) | |
;;(add-to-list 'auto-mode-alist '("\\.purs$" . haskell-mode)) | |
;;(custom-set-variables | |
;; '(js2-basic-offset 2) | |
;; '(js2-bounce-indent-p t) | |
;;) | |
(global-set-key (kbd "C-x f") 'find-file-in-project) | |
(defun set-exec-path-from-shell-PATH () | |
(let ((path-from-shell (replace-regexp-in-string | |
"[ \t\n]*$" | |
"" | |
(shell-command-to-string "$SHELL --login -i -c 'echo $PATH'")))) | |
(setenv "PATH" path-from-shell) | |
(setq eshell-path-env path-from-shell) ; for eshell users | |
(setq exec-path (split-string path-from-shell path-separator)))) | |
(when window-system (set-exec-path-from-shell-PATH)) | |
(global-set-key (kbd "M-3") '(lambda () (interactive) (insert "#"))) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment