blob: 2af778eeedf739772f157c1b68b8e6388e9b1cd9 [file] [log] [blame]
Luigi Santivetti97e80ab2019-11-03 19:20:05 +00001;;; init.el --- Emacs configuration
2
3;; Copyright (C) 2019 Luigi Santivetti
4
5;; Author: Luigi Santivetti <luigi.santivetti@gmail.com>
6
7;; This program is free software. You can redistribute it and/or modify it under
8;; the terms of the GPL, v3.
9;;
10;; This program is distributed in the hope that it will be useful, but WITHOUT
11;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12;; FOR A PARTICULAR PURPOSE.
13;;
14;; See http://www.wtfpl.net/.
15
16;;; Commentary:
17
18;; Faces are manually edited and vaguely recall SublimeText, I find it balanced.
19;; This configuration file works for me, but I DO NOT KNOW lisp, when you find
20;; any problem let me know the fix :P - thanks.
21
22;;; Code:
23
24;;,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,;;
25;; Debian Stretch Emacs default version
26;;'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';;
27(when (< (string-to-number (concat
28 (number-to-string emacs-major-version)
29 "."
30 (number-to-string emacs-minor-version))) 24.4)
31 (error "Version >= 24.5 is required."))
32
33;;,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,;;
34;; Install packages
35;;'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';;
36(require 'package)
37(package-initialize t)
38
39(add-to-list 'package-archives
40 '("melpa" . "https://melpa.org/packages/") t)
41(when (< emacs-major-version 24)
42 (add-to-list 'package-archives
43 '("gnu" . "https://elpa.gnu.org/packages/")))
44
45(package-initialize)
46
47(setq package-selected-packages
48 '(diff-hl
49 multiple-cursors
50 smooth-scroll
51 markdown-mode
52 smart-mode-line-powerline-theme
53 rainbow-delimiters))
54
55(unless package-archive-contents
56 (package-refresh-contents))
57
58(dolist (package package-selected-packages)
59 (unless (package-installed-p package)
60 (message "Missing packages detected, please wait...")
61 (package-install package)))
62
63;;,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,;;
64;; Custom set variables
65;;'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';;
66(custom-set-variables
67 '(column-number-mode t)
68 '(cua-mode t nil (cua-base))
69 '(custom-enabled-themes (quote (smart-mode-line-powerline)))
70 '(custom-safe-themes
71 (quote
72 ("84d2f9eeb3f82d619ca4bfffe5f157282f4779732f48a5ac1484d94d5ff5b279" default)))
73 '(fill-column 80)
74 '(global-hl-line-mode t)
75 '(global-linum-mode t)
76 '(inhibit-startup-screen t)
77 '(show-paren-mode t)
78 '(tool-bar-mode nil))
79
80;;,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,;;
81;; Custom set faces
82;;'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';;
83(custom-set-faces
84 '(default ((t (:background "#343D46" :foreground "#D8DEE9" :slant normal
85 :weight normal :width ultracondensed
86 :foundry "adobe" :family "Source Code Variable"))))
87 '(font-lock-comment-face ((t (:background "#343D46" :foreground "#848B97"))))
88 '(fringe ((t (:background "#343D46"))))
89 '(hl-line ((t (:background "#2C3133"))))
90 '(linum ((t (:slant normal :width ultracondensed :foreground "#848B97"))))
91 '(mode-line ((t (:background "#4E5A65" :foreground "#D8DEE9" :box nil))))
92 '(mode-line-buffer-id-inactive ((t (:inherit mode-line-buffer-id
93 :background "#757B81"
94 :foreground "#D8DEE9"))))
95 '(mode-line-highlight ((t (:box (:line-width 2 :color "#4E5A65"
96 :style released-button)))))
97 '(mode-line-inactive ((t (:background "#4E5A65" :foreground "#4E5A65"
98 :box nil))))
99 '(powerline-active1 ((t (:inherit sml/global :background "#4E5A65"
100 :foreground "#D8DEE9"))))
101 '(powerline-active2 ((t (:inherit sml/global :background "#757B81"
102 :foreground "#D8DEE9"))))
103 '(powerline-inactive1 ((t (:inherit mode-line-inactive
104 :background "#4E5A65"))))
105 '(powerline-inactive2 ((t (:inherit mode-line-inactive
106 :background "#4E5A65"))))
107 '(rainbow-delimiters-depth-1-face ((t (:foreground "dark orange"))))
108 '(rainbow-delimiters-depth-2-face ((t (:foreground "deep pink"))))
109 '(rainbow-delimiters-depth-3-face ((t (:foreground "chartreuse"))))
110 '(rainbow-delimiters-depth-4-face ((t (:foreground "deep sky blue"))))
111 '(rainbow-delimiters-depth-5-face ((t (:foreground "yellow"))))
112 '(rainbow-delimiters-depth-6-face ((t (:foreground "orchid"))))
113 '(rainbow-delimiters-depth-7-face ((t (:foreground "spring green"))))
114 '(rainbow-delimiters-depth-8-face ((t (:foreground "sienna1"))))
115 '(region ((t (:background "#4E5A65" :foreground "#D8DEE9"))))
116 '(sml/col-number ((t (:inherit sml/global :background "#4E5A65"
117 :foreground "white" :weight bold))))
118 '(sml/filename ((t (:inherit sml/global :background "#4E5A65"
119 :foreground "black"))))
120 '(sml/global ((t (:background "#4E5A65" :foreground "#D8DEE9"))))
121 '(sml/line-number ((t (:inherit sml/global :background "#4E5A65"
122 :foreground "White" :weight bold))))
123 '(sml/modes ((t (:inherit sml/global :background "#757B81"
124 :foreground "Black"))))
125 '(sml/mule-info ((t (:inherit sml/global :background "#4E5A65"))))
126 '(sml/name-filling ((t (:inherit sml/prefix :background "#757B81"
127 :weight normal))))
128 '(sml/not-modified ((t (:inherit sml/global :background "#4E5A65"))))
129 '(sml/numbers-separator ((t (:inherit sml/col-number :background "#4E5A65"))))
130 '(sml/position-percentage ((t (:inherit sml/prefix :background "#757B81"
131 :foreground "orange" :weight normal))))
132 '(sml/prefix ((t (:inherit sml/global :background "#4E5A65"
133 :foreground "orange"))))
134 '(sml/process ((t (:inherit sml/prefix :background "#757B81"))))
135 '(sml/remote ((t (:inherit sml/global :background "#4E5A65"))))
136 '(sml/time ((t (:inherit sml/global :background "black"
137 :foreground "dark orange"))))
138 '(sml/vc ((t (:inherit sml/git :background "#757B81" :foreground "#0000aa"))))
139 '(sml/vc-edited ((t (:inherit sml/prefix :background "#757B81"
140 :foreground "#330000")))))
141
142;;,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,;;
143;; Smoother scroll
144;;'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';;
145(setq mouse-wheel-scroll-amount '(1 ((shift) . 1))) ;; one line at a time
146(setq mouse-wheel-progressive-speed nil) ;; don't accelerate scrolling
147(setq mouse-wheel-follow-mouse 't) ;; scroll window under mouse
148(setq scroll-step 1) ;; keyboard scroll one line at a time
149(setq margin 1) ;; keyboard scroll one line at a time
150(require 'smooth-scroll)
151
152;;,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,;;
153;; Buffer list cleanup
154;;'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';;
155(add-hook 'kill-buffer-hook
156 (lambda ()
157 (setq buffer-name-history
158 (delete (buffer-name) buffer-name-history))))
159(setq history-delete-duplicates t)
160
161;;,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,;;
162;; Rainbow delimiters
163;;'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';;
164(add-hook 'prog-mode-hook #'rainbow-delimiters-mode)
165
166;;,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,;;
167;; Powerline theme
168;;'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';;
169(setq powerline-default-separator 'arrow)
170(setq sml/theme 'powerline)
171(require 'smart-mode-line)
172(sml/setup)
173
174;;,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,;;
175;; Fringe
176;;'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';;
177(fringe-mode '(12 . 0))
178
179;;,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,;;
180;; Line number format
181;;'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';;
182(setq linum-format "%5.5s")
183
184;;,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,;;
185;; Highlight matching bracket
186;;'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';;
187(show-paren-mode 1)
188(setq show-paren-delay 0)
189(require 'paren)
190(set-face-background 'show-paren-match (face-background 'default))
191(set-face-foreground 'show-paren-match "#def")
192(set-face-attribute 'show-paren-match nil :weight 'extra-bold)
193
194;;,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,;;
195;; Custom bash mode, thanks gker
196;;'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';;
197(defun gker-setup-sh-mode ()
198 "My own personal preferences for `sh-mode'.
199
200This is a custom function that sets up the parameters I usually
201prefer for `sh-mode'. It is automatically added to
202`sh-mode-hook', but is can also be called interactively."
203 (interactive)
204 (setq sh-basic-offset 4
205 sh-indentation 4
206 tab-width 4))
207(add-hook 'sh-mode-hook 'gker-setup-sh-mode)
208
209;;,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,;;
210;; Git diff hl
211;;'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';;
212(require 'diff-hl)
213(global-diff-hl-mode 1)
214(diff-hl-flydiff-mode 1)
215(add-hook 'dired-mode-hook 'diff-hl-dired-mode)
216
217;;,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,;;
218;; Multiple cursors
219;;'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';;
220(require 'multiple-cursors)
221(global-set-key (kbd "C-S-c C-S-c") 'mc/edit-lines)
222(global-set-key (kbd "M-<down>") 'mc/mark-next-like-this)
223(global-set-key (kbd "M-<up>") 'mc/mark-previous-like-this)
224(global-set-key (kbd "M-C-<down>") 'mc/mark-all-like-this)
225(global-set-key (kbd "C-S-<mouse-1>") 'mc/add-cursor-on-click)
226
227;;,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,;;
228;; Disable beep
229;;'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';;
230(setq ring-bell-function 'ignore)
231
232;;,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,;;
233;; Stop spamming files
234;;'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';;
235(setq make-backup-files nil) ; stop creating backup~ files
236(setq auto-save-default nil) ; stop creating #autosave# files
237(setq create-lockfiles nil) ; stop hard links
238
239;;,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,;;
240;; No scroll bar in minibuffer
241;;'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';;
242(set-window-scroll-bars (minibuffer-window) nil nil)
243
244;;,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,;;
245;; Furter customization for linum and left margin width
246;;'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';;
247;(eval-after-load "linum"
248; '(set-face-attribute 'linum nil :height 80))
249(set-default-font "Source Code Variable-12")
250
251;;,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,;;
252;; Maximise Emacs
253;;'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';;
254(add-to-list 'default-frame-alist '(fullscreen . maximized))
255
256;;; init.el ends here