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