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