]> git.rkrishnan.org Git - .emacs.d.git/blob - init.el
refactor haskell stuff
[.emacs.d.git] / init.el
1 (package-initialize)
2 (show-paren-mode 1)
3 ;; y-or-n instead of yes-or-no
4 (defalias 'yes-or-no-p 'y-or-n-p)
5
6 ;; Don't show startup msg, don't store tilde files
7 (setq make-backup-files nil)
8 (setq initial-scratch-message "")
9 (setq inhibit-startup-message t)
10
11 ;; turn OFF syntax highlighting
12 (global-font-lock-mode 0)
13
14 ;; cursor bar
15 (setq-default cursor-type '(bar . 2))
16
17 ;; column number
18 (column-number-mode 1)
19
20 ;; font
21 ;; (set-default-font "Inconsolata-12")
22 (set-default-font "InconsolataGo-12")
23
24 ;; Don't let Emacs hurt your ears
25 (setq visible-bell t)
26
27 ;; This is bound to f11 in Emacs 24.4
28 ;; (toggle-frame-fullscreen)
29 (custom-set-variables
30  ;; custom-set-variables was added by Custom.
31  ;; If you edit it by hand, you could mess it up, so be careful.
32  ;; Your init file should contain only one such instance.
33  ;; If there is more than one, they won't work right.
34  '(initial-frame-alist (quote ((fullscreen . maximized))))
35  '(send-mail-function (quote smtpmail-send-it)))
36
37 ;; Who use the bar to scroll?
38 (when (display-graphic-p)
39   (progn
40     (scroll-bar-mode 0)
41
42     (tool-bar-mode 0)
43     (menu-bar-mode 0)))
44
45 ;; tangotango
46 ;; (load-theme 'tangotango t)
47 ;; (load-theme 'railscasts t)
48 ;; (load-theme 'leuven t)
49
50 ;; erc
51 (require 'erc)
52 (require 'tls)
53 ;; (setq tls-program '("openssl s_client -connect %h:%p -no_ssl2 -ign_eof"))
54
55 (erc-autojoin-mode t)
56 (setq erc-autojoin-channels-alist
57       '((".*\\.freenode.net" "#tahoe-lafs")
58         (".*\\.oftc.net" "#LeastAuthority")
59         ;; (".*\\.mozilla.org" "#rust-beginners")
60         ))
61
62 ;; check channels
63 (erc-track-mode t)
64 (setq erc-track-exclude-types '("JOIN" "NICK" "PART" "QUIT" "MODE"
65                                  "324" "329" "332" "333" "353" "477"))
66 ;; don't show any of this
67 (setq erc-hide-list '("JOIN" "PART" "QUIT" "NICK"))
68
69 (defun start-erc ()
70   "Connect to IRC."
71   (interactive)
72   (when (y-or-n-p "Do you want to start IRC? ")
73     ;; (erc-tls :server "irc.mozilla.org" :port 6697 :nick "rkrishnan" :full-name "Ramakrishnan Muthukrishnan")
74     (erc-tls :server "irc.freenode.net" :port 6697 :nick "rkrishnan" :full-name "Ramakrishnan Muthukrishnan")
75     (erc-tls :server "irc.oftc.net" :port 6697 :nick "rkrishnan" :full-name "Ramakrishnan Muthukrishnan")))
76
77 ;; switch to ERC with Ctrl+c e
78 (global-set-key (kbd "C-c e") 'start-erc) ;; ERC
79
80 ;; ido
81 (setq ido-enable-flex-matching t)
82 (setq ido-everywhere t)
83 (ido-mode 1)
84
85 ;; disable tabs for indentation
86 (setq-default indent-tabs-mode nil)
87
88 ;; (require 'whitespace)
89 ;; (setq whitespace-style '(face lines-tail))
90 ;; (setq whitespace-line-column 80)
91 ;; (global-whitespace-mode t)
92
93 ;; ;; show trailing whitespaces
94 ;; (setq-default show-trailing-whitespace t)
95 ;; (setq-default indicate-empty-lines t)
96
97 ;; C style
98 (setq c-default-style "k&r"
99       c-basic-offset 4)
100
101 ;; haskell
102 (add-hook 'haskell-mode-hook #'hindent-mode)
103
104 (eval-after-load 'haskell-mode
105   '(define-key haskell-mode-map [f8] 'haskell-navigate-imports))
106
107 ;;; ghc-mod
108 (let ((my-cabal-path (expand-file-name "~/.cabal/bin")))
109   (setenv "PATH" (concat my-cabal-path ":" (getenv "PATH")))
110   (add-to-list 'exec-path my-cabal-path))
111
112 (autoload 'ghc-init "ghc" nil t)
113 (autoload 'ghc-debug "ghc" nil t)
114 (add-hook 'haskell-mode-hook (lambda () (ghc-init)))
115
116 ;; hlint
117 (add-to-list 'load-path "~/.emacs.d/hs-lint")
118 (require 'hs-lint)
119 (defun my-haskell-mode-hook ()
120    (local-set-key "\C-cl" 'hs-lint))
121
122 (add-hook 'haskell-mode-hook 'my-haskell-mode-hook)
123
124 ;; gofmt
125 (add-hook 'before-save-hook #'gofmt-before-save)
126 (add-hook 'go-mode-hook (lambda ()
127                           (local-set-key (kbd "C-c C-r")
128                                          'go-remove-unused-imports)))
129 (add-hook 'go-mode-hook (lambda ()
130                           (local-set-key (kbd "C-c i")
131                                          'go-goto-imports)))
132
133 ;; asp
134 (add-to-list 'load-path "~/.emacs.d/asp-mode")
135 (autoload 'asp-mode "asp-mode")
136 (setq auto-mode-alist
137       (cons '("\\.asp\\'" . asp-mode) auto-mode-alist))
138
139 ;; line-number-mode
140 (global-linum-mode t)
141 (global-hl-line-mode 0)
142
143 ;; fci -- fill-column-indicator
144 (setq fci-rule-column 81)
145 (setq fci-rule-width 1)
146 (setq fci-rule-color "darkblue")
147
148 ;; turn off electric-indent-mode
149 (when (fboundp 'electric-indent-mode) (electric-indent-mode -1))
150
151 ;; notmuch
152 (setq mail-user-agent 'message-user-agent)
153 (setq user-mail-address "ram@rkrishnan.org"
154       user-full-name "Ramakrishnan Muthukrishnan")
155
156 ;; smtp
157 (setq smtpmail-stream-type 'ssl
158       smtpmail-smtp-server "mail.messagingengine.com"
159       smtpmail-smtp-service 465)
160
161 ;; addressbook
162 (require 'notmuch-address)
163 (setq notmuch-address-command "/usr/bin/notmuch-addrlookup")
164 ;;(notmuch-address-message-insinuate)
165
166 (require 'smtpmail)
167 (setq message-send-mail-function 'smtpmail-send-it)
168 (require 'starttls)
169
170 ;; sign all emails
171 (add-hook 'message-setup-hook 'mml-secure-message-sign-pgp)
172
173 (custom-set-faces
174  ;; custom-set-faces was added by Custom.
175  ;; If you edit it by hand, you could mess it up, so be careful.
176  ;; Your init file should contain only one such instance.
177  ;; If there is more than one, they won't work right.
178  )
179
180 ;; company mode for auto completion
181 (add-hook 'after-init-hook 'global-company-mode)
182
183 ;; Reduce the time after which the company auto completion popup opens
184 (setq company-idle-delay 0.2)
185
186 ;; Reduce the number of characters before company kicks in
187 (setq company-minimum-prefix-length 1)
188
189 ;; Set path to racer binary
190 (setq racer-cmd "/home/ram/.cargo/bin/racer")
191
192 (add-hook 'rust-mode-hook
193           '(lambda ()
194              (racer-activate)
195              (racer-turn-on-eldoc)
196              (add-hook 'flycheck-mode-hook #'flycheck-rust-setup)
197              (set (make-local-variable 'company-backends) '(company-racer))
198              (local-set-key (kbd "M-.") #'racer-find-definition)
199              (local-set-key (kbd "TAB") #'racer-complete-or-indent)))
200
201 ;; highlight todo
202 ;; (add-hook 'prog-mode-hook 'highlight-todos)
203
204 ;; Ledger
205 (setq ledger-binary-path "~/.cabal/bin/hledger")
206
207 ;; golang
208 (setq exec-path (cons "/usr/local/go/bin" exec-path))
209 (add-to-list 'exec-path (concat (getenv "GOPATH") "/bin"))
210
211 (defun go-mode-setup ()
212   (go-eldoc-setup)
213   (setq gofmt-command "goimports")
214   (add-hook 'before-save-hook 'gofmt-before-save))
215
216 (add-hook 'go-mode-hook 'go-mode-setup)
217
218 ;; alias man to w.o.man
219 (defalias 'man 'woman)
220
221 ;; eshell aliases
222 (defun eshell/emacs (&rest args)
223   "open a file in emacs"
224   (if (null args)
225       (bury-buffer)
226     (mapc #'find-file (mapcar #'expand-file-name (eshell-flatten-list (reverse args))))))
227
228 ;(desktop-save-mode 1)
229
230 ;; which function?
231 (which-func-mode 1)
232 (add-to-list 'which-func-modes '(c-mode c++-mode rust-mode haskell-mode))
233
234 ;; flysheck
235 ;; (add-hook 'after-init-hook #'global-flycheck-mode)
236
237