Guest User

Haskell Emacs configuration

a guest
Jul 11th, 2013
866
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. _____________
  2.  
  3. EMACS-SETUP
  4.  
  5. Lemao
  6. _____________
  7.  
  8.  
  9. Table of Contents
  10. _________________
  11.  
  12. 1 Emacs installation
  13. 2 MELPA package repository
  14. 3 Flycheck installation
  15. 4 Auto-complete installation
  16. 5 Haskell support installation
  17.  
  18.  
  19. 1 Emacs installation
  20. ====================
  21.  
  22. 1. Install [Emacs 24 Starter-kit]
  23. ,----
  24. | git clone http://github.com/eschulte/emacs24-starter-kit.git .emacs.d
  25. `----
  26. 1. Run 'emacs' to complete the installation
  27.  
  28.  
  29. [Emacs 24 Starter-kit] http://eschulte.github.io/emacs24-starter-kit/
  30.  
  31.  
  32. 2 MELPA package repository
  33. ==========================
  34.  
  35. 1. Edit ~/.emacs.d/${USER}.el
  36. ,----
  37. | ;; [==:INIT package manager==]
  38. | (require 'package)
  39. | (add-to-list 'package-archives '("melpa" . "http://melpa.milkbox.net/packages/") t)
  40. | (package-initialize)
  41. `----
  42.  
  43. 1. Restart emacs and refresh package contents
  44. ,----
  45. | M-x package-refresh-contents RET
  46. `----
  47.  
  48. NOTE: you should see refreshing package contents from
  49. melpa.milkbox.net
  50.  
  51.  
  52. 3 Flycheck installation
  53. =======================
  54.  
  55. 1. Install flycheck
  56. ,----
  57. | M-x package-install RET flycheck RET
  58. `----
  59.  
  60. 1. Install flycheck color mode line
  61. ,----
  62. | M-x package-install RET flycheck-color-mode-line RET
  63. `----
  64.  
  65. 1. Configure flycheck
  66. Add the following to your ~/.emacs.d/${USER}.el:
  67. ,----
  68. | ;; [==:INIT flycheck==]
  69. | (add-hook 'after-init-hook 'global-flycheck-mode)
  70. | ;; (setq flycheck-check-syntax-automatically '(mode-enabled idle-change))
  71. |
  72. | ;; (require 'flycheck-color-mode-line))
  73. | ;; (eval-after-load "flycheck"
  74. | ;; '(add-hook 'flycheck-mode-hook 'flycheck-color-mode-line-mode))
  75. `----
  76.  
  77.  
  78. 4 Auto-complete installation
  79. ============================
  80.  
  81. 1. Install the auto-complete package
  82. ,----
  83. | M-x package-install RET auto-complete RET
  84. `----
  85.  
  86. 1. Configure auto-complete
  87. ,----
  88. | ;; [==:INIT flycheck==]
  89. | (require 'auto-complete)
  90. `----
  91.  
  92.  
  93. 5 Haskell support installation
  94. ==============================
  95.  
  96. 1. Install Haskell Platform
  97.  
  98. 2. Update cabal repository
  99. ,----
  100. | cabal update
  101. `----
  102.  
  103. 1. Install cabal packages
  104. ,----
  105. | cabal install hdevtools ghc-mod hlint stylish-haskell
  106. `----
  107.  
  108. 1. Install Haskell Emacs front-end(s)
  109. ,----
  110. | M-x package-install RET haskell-mode
  111. | M-x package-install RET ghc
  112. | M-x package-install RET ghci-completion
  113. `----
  114.  
  115. 1. Configure haskell-mode, ghc
  116. ,----
  117. | ;; [==:INIT haskell-mode==]
  118. | (add-hook 'haskell-mode-hook 'turn-on-haskell-indentation)
  119. |
  120. | ;; [==:INIT ghc-mod==]
  121. | (autoload 'ghc-init "ghc" nil t)
  122. | (add-hook 'haskell-mode-hook
  123. | (lambda ()
  124. | (ghc-init)))
  125. |
  126. | ;; [==:INIT auto-complete==]
  127. | (ac-define-source ghc-mod
  128. | '((depends ghc)
  129. | (candidates . (ghc-select-completion-symbol))
  130. | (symbol . "s")
  131. | (cache)))
  132. |
  133. | (defun my-ac-haskell-mode ()
  134. | (setq ac-sources '(ac-source-words-in-same-mode-buffers
  135. | ac-source-dictionary
  136. | ac-source-ghc-mod)))
  137. | (add-hook 'haskell-mode-hook 'my-ac-haskell-mode)
  138. |
  139. |
  140. | ;; [==:INIT fnd-file-hook==]
  141. | (defun my-haskell-ac-init ()
  142. | (when (member (file-name-extension buffer-file-name) '("hs" "lhs"))
  143. | (auto-complete-mode t)
  144. | (setq ac-sources '(ac-source-words-in-same-mode-buffers
  145. | ac-source-dictionary
  146. | ac-source-ghc-mod))))
  147. | (add-hook 'find-file-hook 'my-haskell-ac-init)
  148. `----
RAW Paste Data