Luigi Santivetti | 4ab714f | 2019-11-08 10:10:48 +0000 | [diff] [blame] | 1 | ;;; 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 | (add-to-list 'package-archives |
| 42 | '("gnu" . "https://elpa.gnu.org/packages/")) |
| 43 | |
| 44 | (package-initialize) |
| 45 | |
| 46 | (setq package-selected-packages |
| 47 | '(diff-hl |
| 48 | multiple-cursors |
| 49 | smooth-scroll |
| 50 | markdown-mode |
| 51 | smart-mode-line-powerline-theme |
| 52 | rainbow-delimiters |
| 53 | nlinum)) |
| 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 | '(nlinum-highlight-current-line t) |
| 76 | '(global-nlinum-mode t) |
| 77 | '(inhibit-startup-screen t) |
| 78 | '(show-paren-mode t) |
| 79 | '(tool-bar-mode nil)) |
| 80 | |
| 81 | ;;,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,;; |
| 82 | ;; Custom set faces |
| 83 | ;;'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';; |
| 84 | (custom-set-faces |
| 85 | '(default ((t (:background "#343D46" :foreground "#D8DEE9" :slant normal |
| 86 | :weight normal :width normal :foundry "adobe" |
| 87 | :family "Source Code Pro")))) |
| 88 | '(font-lock-comment-face ((t (:background "#343D46" :foreground "#848B97")))) |
| 89 | '(fringe ((t (:background "#343D46")))) |
| 90 | '(hl-line ((t (:background "#2C3133" :weight bold)))) |
| 91 | '(nlinum-current-line ((t (:background "#2C3133" :foreground "white" |
| 92 | :weight bold :height 80)))) |
| 93 | '(nlinum ((t (:slant normal :width ultra-condensed :foreground "#848B97")))) |
| 94 | '(mode-line ((t (:background "#4E5A65" :foreground "#D8DEE9" :box nil)))) |
| 95 | '(mode-line-buffer-id-inactive ((t (:inherit mode-line-buffer-id |
| 96 | :background "#757B81" |
| 97 | :foreground "#D8DEE9")))) |
| 98 | '(mode-line-highlight ((t (:box (:line-width 2 :color "#4E5A65" |
| 99 | :style released-button))))) |
| 100 | '(mode-line-inactive ((t (:background "#4E5A65" :foreground "#4E5A65" |
| 101 | :box nil)))) |
| 102 | '(powerline-active1 ((t (:inherit sml/global :background "#4E5A65" |
| 103 | :foreground "#D8DEE9")))) |
| 104 | '(powerline-active2 ((t (:inherit sml/global :background "#757B81" |
| 105 | :foreground "#D8DEE9")))) |
| 106 | '(powerline-inactive1 ((t (:inherit mode-line-inactive |
| 107 | :background "#4E5A65")))) |
| 108 | '(powerline-inactive2 ((t (:inherit mode-line-inactive |
| 109 | :background "#4E5A65")))) |
| 110 | '(rainbow-delimiters-depth-1-face ((t (:foreground "dark orange")))) |
| 111 | '(rainbow-delimiters-depth-2-face ((t (:foreground "deep pink")))) |
| 112 | '(rainbow-delimiters-depth-3-face ((t (:foreground "chartreuse")))) |
| 113 | '(rainbow-delimiters-depth-4-face ((t (:foreground "deep sky blue")))) |
| 114 | '(rainbow-delimiters-depth-5-face ((t (:foreground "yellow")))) |
| 115 | '(rainbow-delimiters-depth-6-face ((t (:foreground "orchid")))) |
| 116 | '(rainbow-delimiters-depth-7-face ((t (:foreground "spring green")))) |
| 117 | '(rainbow-delimiters-depth-8-face ((t (:foreground "sienna1")))) |
| 118 | '(region ((t (:background "#4E5A65" :foreground "#D8DEE9")))) |
| 119 | '(sml/col-number ((t (:inherit sml/global :background "#4E5A65" |
| 120 | :foreground "white" :weight bold)))) |
| 121 | '(sml/filename ((t (:inherit sml/global :background "#4E5A65" |
| 122 | :foreground "black")))) |
| 123 | '(sml/global ((t (:background "#4E5A65" :foreground "#D8DEE9")))) |
| 124 | '(sml/line-number ((t (:inherit sml/global :background "#4E5A65" |
| 125 | :foreground "White" :weight bold)))) |
| 126 | '(sml/modes ((t (:inherit sml/global :background "#757B81" |
| 127 | :foreground "Black")))) |
| 128 | '(sml/mule-info ((t (:inherit sml/global :background "#4E5A65")))) |
| 129 | '(sml/name-filling ((t (:inherit sml/prefix :background "#757B81" |
| 130 | :weight normal)))) |
| 131 | '(sml/not-modified ((t (:inherit sml/global :background "#4E5A65")))) |
| 132 | '(sml/numbers-separator ((t (:inherit sml/col-number :background "#4E5A65")))) |
| 133 | '(sml/position-percentage ((t (:inherit sml/prefix :background "#757B81" |
| 134 | :foreground "orange" :weight normal)))) |
| 135 | '(sml/prefix ((t (:inherit sml/global :background "#4E5A65" |
| 136 | :foreground "orange")))) |
| 137 | '(sml/process ((t (:inherit sml/prefix :background "#757B81")))) |
| 138 | '(sml/remote ((t (:inherit sml/global :background "#4E5A65")))) |
| 139 | '(sml/time ((t (:inherit sml/global :background "black" |
| 140 | :foreground "dark orange")))) |
| 141 | '(sml/vc ((t (:inherit sml/git :background "#757B81" :foreground "#0000aa")))) |
| 142 | '(sml/vc-edited ((t (:inherit sml/prefix :background "#757B81" |
| 143 | :foreground "#330000"))))) |
| 144 | |
| 145 | ;;,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,;; |
| 146 | ;; Smoother scroll |
| 147 | ;;'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';; |
| 148 | (setq mouse-wheel-scroll-amount '(1 ((shift) . 1))) ;; one line at a time |
| 149 | (setq mouse-wheel-progressive-speed nil) ;; don't accelerate scrolling |
| 150 | (setq mouse-wheel-follow-mouse 't) ;; scroll window under mouse |
| 151 | (setq scroll-step 1) ;; keyboard scroll one line at a time |
| 152 | (setq margin 1) ;; keyboard scroll one line at a time |
| 153 | (require 'smooth-scroll) |
| 154 | |
| 155 | ;;,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,;; |
| 156 | ;; Buffer list cleanup |
| 157 | ;;'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';; |
| 158 | (add-hook 'kill-buffer-hook |
| 159 | (lambda () |
| 160 | (setq buffer-name-history |
| 161 | (delete (buffer-name) buffer-name-history)))) |
| 162 | (setq history-delete-duplicates t) |
| 163 | |
| 164 | ;;,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,;; |
| 165 | ;; Rainbow delimiters |
| 166 | ;;'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';; |
| 167 | (add-hook 'prog-mode-hook #'rainbow-delimiters-mode) |
| 168 | |
| 169 | ;;,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,;; |
| 170 | ;; Powerline theme |
| 171 | ;;'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';; |
| 172 | (setq powerline-default-separator 'arrow) |
| 173 | (setq sml/theme 'powerline) |
| 174 | (require 'smart-mode-line) |
| 175 | (sml/setup) |
| 176 | |
| 177 | ;;,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,;; |
| 178 | ;; Fringe |
| 179 | ;;'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';; |
| 180 | (fringe-mode '(10 . 0)) |
| 181 | |
| 182 | ;;,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,;; |
| 183 | ;; Line number format |
| 184 | ;;'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';; |
| 185 | (setq nlinum-format "%5.5s") |
| 186 | |
| 187 | ;;,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,;; |
| 188 | ;; Highlight matching bracket |
| 189 | ;;'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';; |
| 190 | (show-paren-mode 1) |
| 191 | (setq show-paren-delay 0) |
| 192 | (require 'paren) |
| 193 | (set-face-background 'show-paren-match (face-background 'default)) |
| 194 | (set-face-foreground 'show-paren-match "#def") |
| 195 | (set-face-attribute 'show-paren-match nil :weight 'extra-bold) |
| 196 | |
| 197 | ;;,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,;; |
| 198 | ;; Custom bash mode, thanks gker |
| 199 | ;;'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';; |
| 200 | (defun gker-setup-sh-mode () |
| 201 | "My own personal preferences for `sh-mode'. |
| 202 | |
| 203 | This is a custom function that sets up the parameters I usually |
| 204 | prefer for `sh-mode'. It is automatically added to |
| 205 | `sh-mode-hook', but is can also be called interactively." |
| 206 | (interactive) |
| 207 | (setq sh-basic-offset 4 |
| 208 | sh-indentation 4 |
| 209 | tab-width 4)) |
| 210 | (add-hook 'sh-mode-hook 'gker-setup-sh-mode) |
| 211 | |
| 212 | ;;,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,;; |
| 213 | ;; Git diff hl |
| 214 | ;;'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';; |
| 215 | (require 'diff-hl) |
| 216 | (global-diff-hl-mode 1) |
| 217 | (diff-hl-flydiff-mode 1) |
| 218 | (add-hook 'dired-mode-hook 'diff-hl-dired-mode) |
| 219 | |
| 220 | ;;,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,;; |
| 221 | ;; Multiple cursors |
| 222 | ;;'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';; |
| 223 | (require 'multiple-cursors) |
| 224 | (global-set-key (kbd "C-S-c C-S-c") 'mc/edit-lines) |
| 225 | (global-set-key (kbd "M-<down>") 'mc/mark-next-like-this) |
| 226 | (global-set-key (kbd "M-<up>") 'mc/mark-previous-like-this) |
| 227 | (global-set-key (kbd "M-C-<down>") 'mc/mark-all-like-this) |
| 228 | (global-set-key (kbd "C-S-<mouse-1>") 'mc/add-cursor-on-click) |
| 229 | |
| 230 | ;;,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,;; |
| 231 | ;; Disable beep |
| 232 | ;;'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';; |
| 233 | (setq ring-bell-function 'ignore) |
| 234 | |
| 235 | ;;,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,;; |
| 236 | ;; Stop spamming files |
| 237 | ;;'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';; |
| 238 | (setq make-backup-files nil) ; stop creating backup~ files |
| 239 | (setq auto-save-default nil) ; stop creating #autosave# files |
| 240 | (setq create-lockfiles nil) ; stop hard links |
| 241 | |
| 242 | ;;,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,;; |
| 243 | ;; No scroll bar in minibuffer |
| 244 | ;;'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';; |
| 245 | (set-window-scroll-bars (minibuffer-window) nil nil) |
| 246 | |
| 247 | ;;,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,;; |
| 248 | ;; Furter customization for linum and left margin width |
| 249 | ;;'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';; |
Luigi Santivetti | 2cb89dd | 2019-11-11 13:24:54 +0000 | [diff] [blame] | 250 | (eval-after-load "nlinum" |
| 251 | '(set-face-attribute 'linum nil :height 80)) |
Luigi Santivetti | 4ab714f | 2019-11-08 10:10:48 +0000 | [diff] [blame] | 252 | (set-default-font "Source Code Pro-12") |
| 253 | |
| 254 | ;;,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,;; |
Luigi Santivetti | 2cb89dd | 2019-11-11 13:24:54 +0000 | [diff] [blame] | 255 | ;; Emacsclient workaround for nlinum |
| 256 | ;;'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';; |
| 257 | (defun initialize-nlinum (&optional frame) |
| 258 | (require 'nlinum) |
| 259 | (add-hook 'prog-mode-hook 'nlinum-mode)) |
| 260 | (when (daemonp) |
| 261 | (add-hook 'window-setup-hook 'initialize-nlinum) |
| 262 | (defadvice make-frame (around toggle-nlinum-mode compile activate) |
| 263 | (nlinum-mode -1) ad-do-it (nlinum-mode 1))) |
| 264 | |
| 265 | ;;,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,;; |
Luigi Santivetti | 345f8a5 | 2019-12-21 22:05:46 +0000 | [diff] [blame] | 266 | ;; Start Emacs in real fullscreen - no windowed |
Luigi Santivetti | 4ab714f | 2019-11-08 10:10:48 +0000 | [diff] [blame] | 267 | ;;'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';; |
Luigi Santivetti | 345f8a5 | 2019-12-21 22:05:46 +0000 | [diff] [blame] | 268 | (defun fullscreen () |
| 269 | (interactive) |
| 270 | (x-send-client-message nil 0 nil "_NET_WM_STATE" 32 |
| 271 | '(2 "_NET_WM_STATE_FULLSCREEN" 0))) |
| 272 | (fullscreen) |
Luigi Santivetti | 4ab714f | 2019-11-08 10:10:48 +0000 | [diff] [blame] | 273 | |
| 274 | ;;,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,;; |
| 275 | ;; Mail client |
| 276 | ;;'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';; |
| 277 | (defconst user-init-dir |
| 278 | (cond ((boundp 'user-emacs-directory) |
| 279 | user-emacs-directory) |
| 280 | ((boundp 'user-init-directory) |
| 281 | user-init-directory) |
| 282 | (t "~/.emacs.d/"))) |
| 283 | |
| 284 | (defun load-user-file (file) |
| 285 | (interactive "f") |
| 286 | "Load a file in current user's configuration directory" |
| 287 | (load-file (expand-file-name file user-init-dir))) |
| 288 | (load-user-file "mu4e-config.el") |
| 289 | |
| 290 | ;;; init.el ends here |