1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184 | ;; package --- Thooms emacs config
;;; Commentary:
;;; Code:
(require 'cl)
;; Set user infos
(setq user-full-name "blabla")
(setq user-mail-address "blabla")
;; Ask "y" or "n" instead of "yes" or "no". Yes, laziness is great.
(fset 'yes-or-no-p 'y-or-n-p)
;; Highlight corresponding parentheses when cursor is on one
(show-paren-mode t)
;; Highlight tabulations
(setq-default highlight-tabs t)
;; Show trailing white spaces
(setq-default show-trailing-whitespace t)
;; Remove useless whitespace before saving a file
(add-hook 'before-save-hook 'whitespace-cleanup)
(add-hook 'before-save-hook (lambda() (delete-trailing-whitespace)))
;; Final newline handling
(setq require-final-newline t)
;; Save backup files in a dedicated directory
(setq backup-directory-alist '(("." . "~/.saves")))
;; Set locale to UTF8
(set-language-environment 'utf-8)
(set-terminal-coding-system 'utf-8)
(setq locale-coding-system 'utf-8)
(set-default-coding-systems 'utf-8)
(set-selection-coding-system 'utf-8)
(prefer-coding-system 'utf-8)
;;;;;;;;; Package management
;; Add package sources
(package-initialize)
(setq package-archives '(("gnu" . "http://elpa.gnu.org/packages/")
("marmalade" . "http://marmalade-repo.org/packages/")
("melpa" . "http://melpa.org/packages/")))
;; Define user packages
(defvar thooms/packages
'(
exec-path-from-shell ; to benefit from shell-set PATH
grandshell-theme
autopair ; Auto delimiter closing
magit ; git interface
neotree
company ; Autocompletion framework
company-quickhelp
flycheck ; Syntax checking
helm
projectile
helm-projectile
helm-ag
smart-mode-line
yaml-mode
scala-mode
ensime
web-mode
markdown-mode
haskell-mode
python-mode
protobuf-mode
rjsx-mode
;ghc-mod
;company-ghc
;;; Golang
go-mode
company-go
)
"Hallo"
)
;; Sync packages
(defun thooms/packages-installed-p ()
(loop for pkg in thooms/packages
when (not (package-installed-p pkg)) do (return nil)
finally (return t)))
(unless (thooms/packages-installed-p)
(message "%s" "Refreshing package database...")
(package-refresh-contents)
(dolist (pkg thooms/packages)
(when (not (package-installed-p pkg))
(package-install pkg))))
(setq exec-path-from-shell-variables '("PATH"))
(exec-path-from-shell-initialize)
;; Global mode start
(autopair-global-mode)
(global-flycheck-mode)
;; Company setup
(add-hook 'after-init-hook 'global-company-mode)
(add-hook 'after-init-jook 'company-quickhelp-mode)
(setq company-tooltip-limit 20) ; bigger popup window
(setq company-idle-delay .1) ; decrease delay before autocompletion popup shows
(setq company-echo-delay 0) ; remove annoying blinking
(setq company-begin-commands '(self-insert-command)) ; start autocompletion only after typing
;; Go mode custom
(add-hook 'go-mode-hook 'company-mode)
(add-hook 'go-mode-hook (lambda ()
(add-hook 'before-save-hook 'gofmt-before-save) ; gofmt before every save
(setq gofmt-command "gofmt") ; gofmt uses invokes goimports
(local-set-key (kbd "M-.") 'godef-jump)
(set (make-local-variable 'company-backends) '(company-go))
(company-mode)))
;; Editor mods
(setq inhibit-splash-screen t
initial-scratch-message nil)
(scroll-bar-mode -1)
(tool-bar-mode -1)
(menu-bar-mode -1)
(setq column-number-mode t)
(require 'neotree)
(global-set-key [f8] 'neotree-toggle)
;; Sets theme and fonts
(defun frame-config (frame)
"Custom behavior on new frames"
(with-selected-frame frame
(when (display-graphic-p)
(setq frame-title-format '(buffer-file-name "%f" ("%b")))
(set-face-attribute 'default nil
:font "Inconsolata-14"))
(if (display-graphic-p)
(load-theme 'grandshell t)
(load-theme 'grandshell t))
))
(frame-config (selected-frame))
(add-hook 'after-make-frame-functions 'frame-config)
;; Helm and projectile conf
(require 'helm-config)
(helm-mode 1)
(helm-autoresize-mode 1)
(global-set-key (kbd "M-x") 'helm-M-x)
(global-set-key (kbd "C-x C-f") 'helm-find-files)
(global-set-key (kbd "C-x C-b") 'helm-buffers-list)
(projectile-mode)
(helm-projectile-on)
(setq projectile-completion-system 'helm)
(define-key projectile-mode-map (kbd "C-c p") 'projectile-command-map)
;; Smartmodeline conf
(setq sml/no-confirm-load-theme t)
(setq sml/theme 'dark)
(sml/setup)
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(package-selected-packages
(quote
(company-quickhelp yaml-mode web-mode smart-mode-line python-mode markdown-mode helm-projectile helm-ag haskell-mode grandshell-theme flycheck exec-path-from-shell ensime company-go autopair))))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
)
|