aboutsummaryrefslogtreecommitdiff
path: root/home/.emacs.d/init.el
blob: 8222bcff4b8ac514423e5f96fdc8650d696f0f9f (plain) (blame)
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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
;;; General editor configuration

;; clean up interface
(menu-bar-mode -1)
(tool-bar-mode -1)
(scroll-bar-mode -1)
(global-linum-mode t)
(setq column-number-mode t)
(setq inhibit-splash-screen t)
(setq initial-scratch-message nil)
(setq ring-bell-function 'ignore)

;; disable backups, autosave and lockfiles
(setq make-backup-files nil)
(setq backup-inhibited t)
(setq auto-save-default nil)
(setq create-lockfiles nil)
(global-auto-revert-mode t)

;; font
; value is in 1/10pt, so 100 will give you 10pt, etc.
(set-face-attribute 'default nil :height 100)

;; simplify questions
(defalias 'yes-or-no-p 'y-or-n-p)
(setq vc-follow-symlinks t)

;; kill the current buffer immediately (only ask if buffer modified)
(global-set-key (kbd "C-x k") 'kill-this-buffer)

;; set title of frame to current buffer
(setq frame-title-format '(buffer-file-name "%f" "%b"))

;; Highlight corresponding parentheses when cursor is on one
(show-paren-mode t)

;; Show directories first
(setq dired-listing-switches "-alh  --group-directories-first")

;; save customizations to separate file
(setq custom-file (expand-file-name "custom.el" user-emacs-directory))
(load custom-file 'noerror)

(setq initial-buffer-choice "~/readme.org")

;;; Enable use-package

(require 'package)
(add-to-list 'package-archives
	     '("melpa" . "https://melpa.org/packages/"))
(package-initialize)

(when (not package-archive-contents)
  (package-refresh-contents))

(unless (package-installed-p 'use-package)
  (package-install 'use-package))

(require 'use-package)
(setq use-package-verbose t)
(setq use-package-always-ensure t)

;;; Specialized packages

(use-package helm
  :config
  (progn ; progn since order is important here
    (setq helm-candidate-number-limit 100
	  helm-quick-update t
	  helm-M-x-requires-pattern nil
	  helm-M-x-fuzzy-match t
	  helm-buffers-fuzzy-matching t
	  helm-recentf-fuzzy-match t
	  helm-ff-file-name-history-use-recentf t))
  :bind (("C-h a" . helm-apropos)
	 ("C-x b" . helm-buffers-list)
	 ("C-x C-f" . helm-find-files)
	 ("M-y" . helm-show-kill-ring)
	 ("M-x" . helm-M-x)
	 :map helm-map
	 ("<tab>" . helm-execute-persistent-action)
	 ("C-i" . helm-execute-persistent-action) ; make TAB works in terminal
	 ("C-z" . helm-select-action))
  :diminish helm-mode)

(use-package helm-descbinds
  :bind ("C-h b" . helm-descbinds))

(use-package helm-swoop
  :config (setq helm-swoop-pre-input-function
		(lambda () ""))
  :bind ("C-s" . helm-swoop))

(use-package helm-projectile
  :config
  (helm-projectile-on)
  :bind (("C-x p" . helm-projectile)
	 ("C-x P" . helm-projectile-grep)))

(use-package goto-chg
  :commands goto-last-change
  :bind (("C-." . goto-last-change)
         ("C-," . goto-last-change-reverse)))

(use-package popup-imenu
  :commands popup-imenu
  :bind ("M-i" . popup-imenu))

(use-package projectile
  :defer t ; loading is ensured by helm-projectile
  :init
  (setq projectile-use-git-grep t)
  :config
  (projectile-global-mode t)
  :diminish projectile-mode)

(use-package magit
  :bind ("C-x g" . magit-status))

(use-package zoom-frm
  :bind (("C-+" . zoom-all-frames-in)
	 ("C--" . zoom-all-frames-out)
	 ("C-0" . zoom-frm-unzoom)))

(use-package expand-region
  :commands 'er/expand-region
  :bind ("C-=" . er/expand-region))

(defun unfill-paragraph (&optional region)
  ;; http://www.emacswiki.org/emacs/UnfillParagraph
  "Transforms a paragraph in REGION into a single line of text."
  (interactive)
  (let ((fill-column (point-max)))
    (fill-paragraph nil region)))
(define-key global-map "\M-Q" 'unfill-paragraph)

(defun revert-buffer-no-confirm ()
  ;; http://www.emacswiki.org/emacs-en/download/misc-cmds.el
  "Revert buffer without confirmation."
  (interactive)
  (revert-buffer t t))
(global-set-key [f5] 'revert-buffer-no-confirm)

;; Markdown
(use-package markdown-mode
  :mode
  ("\\.markdown\\'" "\\.md\\'")
  :config
  (setq markdown-command "/usr/bin/pandoc"))

;; YML
(use-package yaml-mode
  :mode ("\\.yml\\'" "\\.yaml\\'"))

;; Completion
(use-package company
  :diminish company-mode)

;; Snippets
(use-package yasnippet
  :diminish yas-minor-mode)

;; C
(setq c-default-style "linux")

;; Scala
(use-package scala-mode
  :interpreter ("scala" . scala-mode)
  :config
  (require 'ensime-expand-region)
  (add-hook 'scala-mode-hook
	    (lambda ()
	      (local-set-key (kbd "RET")
			     '(lambda ()
				(interactive)
				(newline-and-indent)
				(scala-indent:insert-asterisk-on-multiline-comment)))
	      (setq fill-column 80)
	      (ensime-mode)))
  :bind (:map scala-mode-map
	      ("C-<tab>" . dabbrev-expand)
	      ("<backtab>" . scala-indent:indent-with-reluctant-strategy)))

;; ENhanced Scala Interaction Mode for text Editors
(use-package ensime
  :pin melpa ;; pining to melpa uses cutting-edge snapshot version
  :commands ensime ensime-mode
  :init
  :config
  (setq ensime-startup-notification nil
	ensime-startup-snapshot-notification nil))

;; Java
(add-hook 'java-mode-hook (lambda ()
			    (setq c-basic-offset 4)))
;; Rust
(use-package rust-mode
  :mode "\\.rs\\'")
(use-package toml-mode
  :mode "\\.toml\\'")

;; Web development
;; Different modes in html files
(use-package web-mode
  :mode "\\.html?\\'")

;; Javascript
(use-package js3-mode
  :mode "\\.js\\'")

;; Haskell
(use-package haskell-mode)

;; Docker
(use-package dockerfile-mode
  :mode "\\Dockerfile\\'")

(use-package spotify
  :bind (("M-s SPC" . spotify-playpause)
	 ("M-s p" . spotify-previous)
	 ("M-s n" . spotify-next)))

(add-to-list 'custom-theme-load-path "~/.emacs.d/themes/monokai-emacs")
(load-theme 'monokai t)