-
-
Save carnotweat/3867448327cb4a34d42637a670766bc3 to your computer and use it in GitHub Desktop.
Emacs Bootstrap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; -*- lexical-binding: t; -*- | |
;;===[ PERFORMANCE ENHANCEMENTS ]=============================================== | |
;; See: | |
;; https://github.com/hlissner/doom-emacs/wiki/FAQ#how-is-dooms-startup-so-fast | |
(defvar file-name-handler-alist-backup file-name-handler-alist) | |
(defvar gc-cons-threshold-backup gc-cons-threshold) | |
(defvar gc-cons-percentage-backup gc-cons-percentage) | |
(setq gc-cons-threshold 402653184 | |
gc-cons-percentage 0.6 | |
file-name-handler-alist nil) | |
(remove-hook 'find-file-hooks 'vc-find-file-hook) | |
(defun reset-performance () | |
(setq gc-cons-threshold gc-cons-threshold-backup | |
gc-cons-percentage gc-cons-percentage-backup | |
file-name-handler-alist file-name-handler-alist-backup)) | |
(defun compile-init-file () | |
(interactive) | |
(byte-compile-file (file-truename user-init-file))) | |
(add-hook 'emacs-startup-hook #'reset-performance) | |
(add-hook 'kill-emacs-hook #'compile-init-file) | |
;;===[ PACKAGE MANAGER ]======================================================== | |
;;---{ Package.el }------------------------------- | |
(setq load-prefer-newer t | |
package-enable-at-startup nil) | |
(setq package-archives | |
'(("melpa" . "https://stable.melpa.org/packages/") | |
("gnu" . "https://elpa.gnu.org/packages/") | |
("marmalade" . "https://marmalade-repo.org/packages/") | |
("tromey" . "https://tromey.com/elpa/"))) | |
;;---{ Straight.el }------------------------------ | |
;; See: https://github.com/raxod502/straight.el | |
(defvar bootstrap-version) | |
(let ((bootstrap-file | |
(expand-file-name "straight/repos/straight.el/bootstrap.el" | |
user-emacs-directory)) | |
(bootstrap-version 5)) | |
(unless (file-exists-p bootstrap-file) | |
(with-current-buffer | |
(url-retrieve-synchronously | |
"https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el" | |
'silent | |
'inhibit-cookies) | |
(goto-char (point-max)) | |
(eval-print-last-sexp))) | |
(load bootstrap-file nil 'nomessage)) | |
(setq straight-use-package-by-default t) | |
;;===[ PACKAGES ]=============================================================== | |
;; Repositories: | |
;; https://stable.melpa.org/ | |
;; http://elpa.gnu.org/ | |
;;---{ Emacs }------------------------------------- | |
;;... Help ... | |
;;(straight-use-package 'eshell-did-you-mean) | |
(straight-use-package 'helpful) | |
(straight-use-package 'info-colors) | |
(straight-use-package 'which-key) | |
;;... Editor ... | |
(straight-use-package 'beacon) | |
(straight-use-package 'color-identifiers-mode) | |
(straight-use-package 'comment-tags) | |
(straight-use-package 'company) | |
(straight-use-package 'company-quickhelp) | |
(straight-use-package 'diff-hl) | |
;;(straight-use-package 'embrace) | |
(straight-use-package 'eval-in-repl) | |
(straight-use-package 'expand-region) | |
(straight-use-package 'highlight-symbol) | |
(straight-use-package 'ialign) | |
(straight-use-package 'iedit) | |
(straight-use-package 'indent-guide) | |
;;(straight-use-package 'isend-mode) | |
(straight-use-package 'rainbow-blocks) | |
(straight-use-package 'rainbow-delimiters) | |
(straight-use-package 'rainbow-identifiers) | |
(straight-use-package 'rainbow-mode) | |
(straight-use-package 'swiper) | |
(straight-use-package 'whitespace-cleanup-mode) | |
;;... UI ... | |
(straight-use-package 'dashboard) | |
(straight-use-package 'diredfl) | |
(straight-use-package 'display-theme) | |
(straight-use-package 'eshell-prompt-extras) | |
;;(straight-use-package 'indicators) | |
;;(straight-use-package 'ipretty) | |
(straight-use-package 'olivetti) | |
;;(straight-use-package 'powerline) | |
(straight-use-package 'smart-mode-line) | |
;;(straight-use-package 'smooth-scrolling) | |
(straight-use-package 'stripe-buffer) | |
;;(straight-use-package 'sublimity) | |
(straight-use-package 'theme-looper) | |
(straight-use-package 'zoom) | |
;;... Workflow ... | |
(straight-use-package 'ace-window) | |
(straight-use-package 'avy) | |
(straight-use-package 'counsel) | |
(straight-use-package 'dired-single) | |
;;(straight-use-package 'epkg) | |
(straight-use-package 'eshell-z) | |
(straight-use-package 'eyebrowse) | |
(straight-use-package 'ibuffer-projectile) | |
(straight-use-package 'ibuffer-sidebar) | |
(straight-use-package 'ibuffer-vc) | |
;;(straight-use-package 'imenu-anywhere) | |
(straight-use-package 'imenu-list) | |
;;(straight-use-package 'imenus) | |
(straight-use-package 'ivy) | |
(straight-use-package 'neotree) | |
(straight-use-package 'no-littering) | |
;;(straight-use-package 'paradox) | |
(straight-use-package 'projectile) | |
(straight-use-package 'vlf) | |
(straight-use-package 'workgroups2) | |
;;---{ Languages }-------------------------------- | |
;;... Lisps ... | |
;; > Emacs Lisp < | |
;;(straight-use-package 'buttercup) | |
;;(straight-use-package 'el-patch) | |
;;(straight-use-package 'elisp-lint) | |
;;(straight-use-package 'elisp-sandbox) | |
;;(straight-use-package 'elsa) | |
;;(straight-use-package 'erefactor) | |
;;(straight-use-package 'eros) | |
;; > Clojure < | |
;;(straight-use-package 'cider) | |
;;(straight-use-package 'typed-clojure-mode) | |
;; > Common Lisp < | |
;;(straight-use-package 'slime) ; Common Lisp | |
;;(straight-use-package 'slime-company) | |
;; > Racket < | |
(straight-use-package 'flymake-racket) | |
(straight-use-package 'racket-mode) | |
;; > Scheme < | |
;;(straight-use-package 'chicken-scheme) | |
;;(straight-use-package 'geiser) | |
;;(straight-use-package 'scheme-complete) | |
;; > Other Lisps < | |
;;(striaght-use-package 'fennel-mode) | |
;;(straight-use-package 'hy-mode) | |
;;(straight-use-package 'picolisp-mode) | |
;;(straight-use-package 'quack) | |
;; > Keyword Highlighting < | |
(straight-use-package 'highlight-defined) | |
(straight-use-package 'highlight-parentheses) | |
(straight-use-package 'highlight-quoted) | |
(straight-use-package 'lisp-extra-font-lock) | |
;;(straight-use-package 'morlock) | |
;; > S-Expression Editing < | |
;;(straight-use-package 'flylisp) | |
;;(straight-use-package 'flyparens) | |
;;(straight-use-package 'lispy) | |
;;(straight-use-package 'lispyville) ; Evil-mode | |
;;(straight-use-package 'on-parens) | |
;;(straight-use-package 'paredit) | |
;;(straight-use-package 'paren-face) | |
;;(straight-use-package 'parinfer) | |
;;(straight-use-package 'sexp-move) | |
(straight-use-package 'smartparens) | |
;;... Haskell ... | |
;;(straight-use-package 'dante) | |
;;(straight-use-package 'haskell-mode) | |
;;(straight-use-package 'hasky-extensions) | |
;;(straight-use-package 'shm) | |
;;... Scala ... | |
;;(straight-use-package 'ensime) | |
(straight-use-package 'sbt-mode) | |
(straight-use-package 'scala-mode) | |
;;... Python ... | |
;;(straight-use-package 'anaconda-mode) | |
;;(straight-use-package 'elpy) | |
;;(straight-use-package 'importmagic) | |
;;... Ruby ... | |
;;(straight-use-package 'inf-ruby) | |
;;(straight-use-package 'robe) ; Ruby | |
;;(straight-use-package 'rspec-mode) ; Ruby | |
;;(straight-use-package 'ruby-block) | |
;;(straight-use-package 'ruby-mode) | |
;;... PHP ... | |
;;(straight-use-package 'company-php) | |
;;(straight-use-package 'php-mode) | |
;;... Markup / Configuration ... | |
;;(straight-use-package 'adoc-mode) | |
;;(straight-use-package 'company-pollen) | |
;;(straight-use-package 'company-math) | |
;;(straight-use-package 'gitconfig-mode) | |
(straight-use-package 'gitignore-mode) | |
;;(straight-use-package 'graphviz-dot-mode) | |
;;(straight-use-package 'ini-mode) | |
(straight-use-package 'markdown-mode) | |
;;(straight-use-package 'pollen-mode) | |
;;(straight-use-package 'scribble-mode) | |
;;(straight-use-package 'ssh-config-mode) | |
(straight-use-package 'todotxt) | |
;;(straight-use-package 'toml-mode) | |
(straight-use-package 'yaml-mode) | |
;;... Org ... | |
;;(straight-use-package 'interleave) | |
(straight-use-package 'org-beautify-theme) | |
;;(straight-use-package 'org-bullets) | |
;;... Shells ... | |
;;(straight-use-package 'insert-shebang) | |
(when (executable-find "bash") | |
(straight-use-package 'bash-completion) | |
(straight-use-package 'company-shell) | |
(straight-use-package 'flymake-shell)) | |
(when (executable-find "nix-env") | |
(straight-use-package 'nix-mode) | |
(straight-use-package 'nix-options)) | |
;; (when (executable-find "powershell") | |
;; (straight-use-package 'powershell)) | |
;;... Web ... | |
;; > HTML < | |
(straight-use-package 'ac-html) | |
(straight-use-package 'ac-html-bootstrap) | |
(straight-use-package 'ac-html-csswatcher) | |
(straight-use-package 'company-web) | |
(straight-use-package 'emmet-mode) | |
;;(straight-use-package 'tagedit) | |
(straight-use-package 'web-mode) | |
;; > Compile-to-JS/CSS < | |
;;(straight-use-package 'coffee-mode) | |
;;(straight-use-package 'dart-mode) | |
(straight-use-package 'elm-mode) | |
(straight-use-package 'flycheck-elm) | |
;;(straight-use-package 'purescript-mode) | |
(straight-use-package 'sourcemap) | |
;;(straight-use-package 'stylus-mode) | |
;;(straight-use-package 'tide) ; TypeScript | |
;; > JS < | |
;;(straight-use-package 'indium) | |
(straight-use-package 'js2-mode) | |
;;(straight-use-package 'js2-refactor) | |
;;(straight-use-package 'js-comint) | |
(straight-use-package 'json-mode) | |
(straight-use-package 'json-navigator) | |
;;(straight-use-package 'tern) | |
;; > Frameworks < | |
;;(straight-use-package 'easy-hugo) | |
(straight-use-package 'play-routes-mode) | |
;; > Tools < | |
(straight-use-package 'httprepl) | |
;;(straight-use-package 'impatient-mode) | |
;;(straight-use-package 'skewer-mode) | |
(straight-use-package 'web-beautify) | |
;;... Other Languages ... | |
(straight-use-package 'ada-mode) | |
(straight-use-package 'alchemist) ; Elixir | |
;;(straight-use-package 'csharp-mode) | |
(straight-use-package 'elixir-mode) | |
;;(straight-use-package 'ess) ; R | |
(straight-use-package 'flycheck-clojure) | |
(straight-use-package 'flycheck-mix) | |
(straight-use-package 'fsharp-mode) | |
;;(straight-use-package 'forth-mode) | |
;;(straight-use-package 'go-mode) | |
;;(straight-use-package 'idris-mode) | |
;;(straight-use-package 'jq-mode) | |
;;(straight-use-package 'julia-mode) | |
(straight-use-package 'modern-cpp-font-lock) | |
;;(straight-use-package 'nim-mode) | |
;;(straight-use-package 'omnisharp-emacs) ; C# | |
;;(straight-use-package 'pine-script-mode) | |
;;(straight-use-package 'proof-general) ; Coq | |
;;(straight-use-package 'rust-mode) | |
;;(straight-use-package 'sqlup-mode) | |
;;---{ Themes }----------------------------------- | |
;; Theme Previews: | |
;; https://peach-melpa.org/ | |
;; https://emacsthemes.com/ | |
;; > Theme Packs < | |
;;(straight-use-package 'base16-theme) | |
;;(straight-use-package 'doom-themes) | |
;;(straight-use-package 'sublime-themes) | |
;; > Individual Themes < | |
;;(straight-use-package 'abyss-theme) | |
(straight-use-package 'ample-zen-theme) | |
(straight-use-package 'atom-one-dark-theme) | |
;;(straight-use-package 'avk-emacs-themes) | |
(straight-use-package 'badger-theme) | |
(straight-use-package 'birds-of-paradise-plus-theme) | |
(straight-use-package 'blackboard-theme) | |
(straight-use-package 'boron-theme) | |
(straight-use-package 'busybee-theme) | |
(straight-use-package 'caroline-theme) | |
(straight-use-package 'challenger-deep-theme) | |
(straight-use-package 'cherry-blossom-theme) | |
(straight-use-package 'clues-theme) | |
(straight-use-package 'creamsody-theme) | |
(straight-use-package 'dark-krystal-theme) | |
(straight-use-package 'darkburn-theme) | |
;;(straight-use-package 'darkmine-theme) | |
(straight-use-package 'dakrone-theme) | |
(straight-use-package 'darktooth-theme) | |
;;(straight-use-package 'dracula-theme) | |
(straight-use-package 'exotica-theme) | |
(straight-use-package 'farmhouse-theme) | |
(straight-use-package 'firecode-theme) | |
(straight-use-package 'flatland-theme) | |
;;(straight-use-package 'flatland-black-theme) | |
;;(straight-use-package 'flatui-dark-theme) | |
(straight-use-package 'gotham-theme) | |
(straight-use-package 'grandshell-theme) | |
(straight-use-package 'gruvbox-theme) | |
(straight-use-package 'hamburg-theme) | |
(straight-use-package 'hc-zenburn-theme) | |
;;(straight-use-package 'inkpot-theme) | |
(straight-use-package 'jazz-theme) | |
(straight-use-package 'kaolin-themes) | |
(straight-use-package 'klere-theme) | |
;;(straight-use-package 'kooten-theme) | |
;;(straight-use-package 'liso-theme) | |
(straight-use-package 'lush-theme) | |
(straight-use-package 'madhat2r-theme) | |
(straight-use-package 'majapahit-theme) | |
;;(straight-use-package 'melancholy-theme) | |
(straight-use-package 'metalheart-theme) | |
(straight-use-package 'moe-theme) | |
(straight-use-package 'mustard-theme) | |
;;(straight-use-package 'mustang-theme) | |
(straight-use-package 'naquadah-theme) | |
(straight-use-package 'night-owl-theme) | |
(straight-use-package 'nimbus-theme) | |
(straight-use-package 'oceanic-theme) | |
(straight-use-package 'omtose-phellack-theme) | |
(straight-use-package 'one-themes) | |
(straight-use-package 'overcast-theme) | |
(straight-use-package 'paganini-theme) | |
(straight-use-package 'panda-theme) | |
(straight-use-package 'peacock-theme) | |
;;(straight-use-package 'poet-theme) | |
;;(straight-use-package 'railscasts-theme) | |
(straight-use-package 'reverse-theme) | |
(straight-use-package 'reykjavik-theme) | |
(straight-use-package 'seti-theme) | |
;;(straight-use-package 'snazzy-theme) ; Depends on base16-theme! | |
;;(straight-use-package 'solarized-theme) | |
(straight-use-package 'soothe-theme) | |
(straight-use-package 'smyx-theme) | |
;;(straight-use-package 'sourcerer-theme) | |
;;(straight-use-package 'spacemacs-theme) | |
;;(straight-use-package 'spacegray-theme) | |
(straight-use-package 'srcery-theme) | |
;;(straight-use-package 'subatomic256-theme) | |
(straight-use-package 'suscolors-theme) | |
;;(straight-use-package 'toxi-theme) | |
(straight-use-package 'twilight-anti-bright-theme) | |
(straight-use-package 'warm-night-theme) | |
(straight-use-package 'yoshi-theme) | |
(straight-use-package 'zeno-theme) | |
(straight-use-package 'zerodark-theme) | |
(straight-use-package 'zweilight-theme) | |
;;===[ HELPER FUNCTIONS ]======================================================= | |
(defun get-current-buffer-name () | |
(if (buffer-file-name) | |
(abbreviate-file-name (buffer-file-name)) | |
"%b")) | |
(defun compile-current-file () | |
"Compile current elisp file" | |
(interactive) | |
(when (and (equal major-mode 'emacs-lisp-mode) | |
buffer-file-name) | |
(byte-compile-file buffer-file-name))) | |
;;===[ PREFERENCES ]============================================================ | |
;;---{ Variables }-------------------------------- | |
(defun set-global-variable-preferences () | |
(setq-default | |
;;... Emacs ... | |
backup-by-copying t | |
backup-directory-alist '((".*" . "~/.emacs.d/backups/")) | |
custom-file (expand-file-name "~/.emacs.d/emacs-custom.el") | |
custom-safe-themes t | |
delete-old-versions t | |
dired-listing-switches "-ahl" | |
fast-but-imprecise-scrolling t | |
frame-title-format '(:eval (get-current-buffer-name)) | |
indent-tabs-mode nil | |
ivy-use-virtual-buffers t | |
ivy-count-format "(%d/%d) " | |
kept-new-versions 4 | |
scroll-step 10 | |
version-control t | |
which-key-side-window-location '(right bottom) | |
;;... Markdown ... | |
markdown-hide-markup t | |
markdown-hide-urls t | |
;;markdown-enable-math t | |
;;... Neotree ... | |
neo-smart-open t | |
neo-window-position 'right | |
neo-show-hidden-files nil | |
projectile-switch-project-action 'neotree-projectile-action)) | |
(defun set-package-customizations () | |
(with-eval-after-load 'comment-tags | |
(add-to-list 'comment-tags-keywords "ANCHOR") | |
(add-to-list 'comment-tags-keywords "SECTION")) | |
(with-eval-after-load 'ensime | |
(setq-default ensime-startup-notification nil)) | |
(with-eval-after-load 'imenu-list | |
(setq-default | |
imenu-list-auto-resize t | |
;;imenu-list-focus-after-activation t | |
)) | |
(with-eval-after-load 'js2-mode | |
(js2-imenu-extras-setup)) | |
(with-eval-after-load 'olivetti | |
(setq-default olivetti-body-width 80)) | |
(with-eval-after-load 'smart-mode-line | |
(setq-default sml/shorten-modes t | |
sml/mode-width 'full | |
sml/theme 'respectful)) | |
(with-eval-after-load 'web-mode | |
(setq-default | |
web-mode-enable-current-column-highlight t | |
web-mode-enable-current-element-highlight t | |
web-mode-markup-indent-offset 2)) | |
(with-eval-after-load 'smartparens | |
(setq-default sp-use-subword t) | |
(sp-with-modes 'fsharp-mode | |
(sp-local-pair "(*" "*)")) | |
(sp-with-modes 'racket-mode | |
(sp-local-pair "#|" "|#")) | |
(sp-with-modes 'web-mode | |
(sp-local-pair "<" ">")))) | |
;;---{ Theme and Font }--------------------------- | |
;; > Themes < | |
(defvar my/favorite-themes-list | |
'(atom-one-dark | |
challenger-deep | |
darktooth | |
exotica | |
farmhouse-dark | |
gruvbox-dark-hard | |
gotham | |
grandshell | |
hamburg | |
kaolin-bubblegum | |
kaolin-valley-dark | |
majaphit-dark | |
night-owl | |
one-dark | |
overcast | |
srcery | |
suscolors | |
twilight-anti-bright | |
zerodark | |
zweilight)) | |
(defvar my/theme 'challenger-deep) | |
;; > Fonts < | |
;; Font Previews: | |
;; http://app.programmingfonts.org/ | |
;; https://github.com/chrissimpkins/codeface | |
(defvar my/favorite-fonts-list | |
'("Input-12" | |
"CamingoCode-13" | |
"Edlo-12" | |
"Hack-12" | |
"Envy Code R-13" | |
"Sudo-16" | |
"Consola Mono-12" | |
"Fantasque Sans Mono-13" | |
"Monoid-12" | |
"Office Code Pro-13" | |
"Consolas-13" | |
"Oxygen Mono-11" | |
"Inconsolata-13" | |
"MonoOne-12" | |
"Metrickal-11" | |
"Mensch-12" | |
"Aurulent Sans Mono-11" | |
"Audimat Mono-13" | |
"Bront-14" | |
"Luculent-12" | |
"Hermit-12" | |
"Unispace-12" | |
"String Literal-10" | |
"Pointfree-13")) | |
(defvar my/proportional-fonts-list | |
'("B612-14" | |
"Lexia Readable-13" | |
"Vollkorn-13" | |
"Roboto-13")) | |
(defvar my/monospace-font "Input-12") | |
(defvar my/proportional-font "B612-14") | |
;; > Set Theme and Font < | |
(defun set-theme-and-font () | |
(interactive) | |
;; Theme Settings | |
(setq-default kaolin-themes-comments-style 'alt) | |
;; Load Theme | |
(load-theme my/theme) | |
;; Set Fonts | |
(add-to-list 'default-frame-alist `(font . ,my/monospace-font)) | |
(add-to-list 'initial-frame-alist `(font . ,my/monospace-font)) | |
(set-face-font 'default my/monospace-font) | |
(set-face-font 'fixed-pitch my/monospace-font) | |
(set-face-font 'fixed-pitch-serif my/monospace-font) | |
(set-face-font 'variable-pitch my/proportional-font) | |
;; Set Faces | |
(with-eval-after-load 'hl-line | |
(set-face-background 'line-number-current-line | |
(face-background 'hl-line))) | |
(with-eval-after-load 'which-func | |
(set-face-foreground 'which-func | |
(face-foreground 'font-lock-function-name-face))) | |
(with-eval-after-load 'stripe-buffer | |
(set-face-background 'stripe-highlight | |
(face-background 'mode-line-inactive)) | |
(set-face-background 'stripe-hl-line | |
(face-background 'cua-rectangle)) | |
(set-face-foreground 'stripe-hl-line | |
(face-foreground 'cua-rectangle))) | |
;; Set Eshell Prompt Theme | |
(with-eval-after-load 'esh-opt | |
(autoload 'epe-theme-lambda "eshell-prompt-extras") | |
(setq-default | |
eshell-highlight-prompt nil | |
eshell-prompt-function 'epe-theme-lambda)) | |
;; Set Window Size | |
(add-to-list 'default-frame-alist '(width . 95))) | |
;;---{ Global Modes }----------------------------- | |
(defun set-global-modes () | |
(interactive) | |
(beacon-mode t) | |
(column-number-mode t) | |
(counsel-mode t) | |
(cua-selection-mode t) | |
(delete-selection-mode t) | |
(eyebrowse-mode t) | |
(eyebrowse-setup-opinionated-keys) | |
(global-display-theme-mode t) | |
(global-hl-line-mode t) | |
(global-subword-mode t) | |
(ivy-mode t) | |
(menu-bar-mode -1) | |
(projectile-mode t) | |
(scroll-bar-mode -1) | |
(show-paren-mode t) | |
(smart-mode-line-enable t) | |
(tool-bar-mode -1) | |
(which-function-mode t) | |
(which-key-mode t)) | |
(defun setup-preferences () | |
(set-global-variable-preferences) | |
(set-package-customizations) | |
(set-global-modes) | |
(set-theme-and-font)) | |
(add-hook 'emacs-startup-hook #'setup-preferences) | |
;;---{ Dashboard }-------------------------------- | |
(setq-default | |
dashboard-startup-banner 'logo | |
dashboard-items '((recents . 7) | |
(projects . 10) | |
(bookmarks . 5))) | |
(dashboard-setup-startup-hook) | |
;;===[ MODE HOOKS ]============================================================= | |
;;---{ Mode Setup Functions }--------------------- | |
;;... Generic Preferences ... | |
(defun set-programming-preferences () | |
;; > Variables < | |
(setq | |
display-line-numbers t | |
electric-pair-mode nil | |
line-spacing 2 | |
show-trailing-whitespace t | |
tab-always-indent nil | |
;;whitespace-style '(face trailing tabs empty) | |
) | |
;; > Modes < | |
(auto-revert-mode t) | |
(comment-tags-mode t) | |
(company-mode t) | |
(company-quickhelp-mode t) | |
(diff-hl-mode t) | |
(highlight-parentheses-mode t) | |
(hs-minor-mode t) | |
(indent-guide-mode t) | |
(rainbow-delimiters-mode t) | |
(smartparens-mode t) | |
(visual-line-mode t) | |
(whitespace-cleanup-mode t)) | |
(defun set-writing-preferences () | |
;; >Variables < | |
(setq line-spacing 4) | |
;; > Modes < | |
(auto-revert-mode t) | |
(diff-hl-mode t) | |
(electric-pair-local-mode t) | |
;;(flyspell-mode t) | |
(highlight-parentheses-mode t) | |
(olivetti-mode t) | |
(variable-pitch-mode t) | |
(visual-line-mode t) | |
;; > Selective Modes < | |
;; Don't cleanup trailing whitespace in Markdown | |
(unless (or (equal major-mode 'markdown-mode) | |
(equal major-mode 'gfm-mode)) | |
(whitespace-cleanup-mode t))) | |
;;... Specific Mode Preferences ... | |
(defun set-ibuffer-preferences () | |
(ibuffer-auto-mode t) | |
(ibuffer-projectile-set-filter-groups) | |
;;(ibuffer-vc-set-filter-groups-by-vc-root) | |
(stripe-buffer-mode t) | |
(stripe-listify-buffer)) | |
(defun set-lisp-preferences () | |
;; > Modes < | |
(electric-pair-local-mode nil) | |
(highlight-quoted-mode t) | |
(lisp-extra-font-lock-mode t) | |
(smartparens-strict-mode t) | |
;; > Selective Modes < | |
(when (equal major-mode 'emacs-lisp-mode) | |
(highlight-defined-mode t)) | |
;; > Smartparens Config < | |
;; Disable completion for single/back-quotes | |
(sp-local-pair major-mode "'" nil :actions nil) | |
(sp-local-pair major-mode "`" nil :actions nil)) | |
(defun set-org-preferences () | |
(setq-default | |
org-hide-emphasis-markers t | |
org-list-allow-alphabetical t | |
org-startup-indented t | |
org-startup-truncated nil | |
org-support-shift-select t) | |
(org-indent-mode t)) | |
(defun set-package-listing-preferences () | |
(stripe-buffer-mode t) | |
(stripe-listify-buffer)) | |
;;---{ Hook Assignments }------------------------- | |
(add-hook 'dired-mode-hook #'diredfl-mode) | |
(add-hook 'ibuffer-mode-hook #'set-ibuffer-preferences) | |
(add-hook 'package-menu-mode-hook #'set-package-listing-preferences) | |
(add-hook 'prog-mode-hook #'set-programming-preferences) | |
(add-hook 'text-mode-hook #'set-writing-preferences) | |
;;... Language Specific ... | |
(add-hook 'c++-mode-hook #'modern-c++-font-lock-mode) | |
(add-hook 'clojure-mode-hook #'set-lisp-preferences) | |
(add-hook 'cider-mode-hook #'set-lisp-preferences) | |
(add-hook 'emacs-lisp-mode-hook #'set-lisp-preferences) | |
(add-hook 'eshell-mode-hook #'smartparens-mode) | |
(add-hook 'lisp-mode-hook #'set-lisp-preferences) | |
(add-hook 'org-mode-hook #'set-org-preferences) | |
(add-hook 'python-mode-hook #'anaconda-mode) | |
(add-hook 'python-mode-hook #'anaconda-eldoc-mode) | |
(add-hook 'racket-mode-hook #'set-lisp-preferences) | |
(add-hook 'racket-repl-mode-hook #'smartparens-mode) | |
(add-hook 'slime-lisp-mode-hook #'smartparens-mode) | |
(add-hook 'web-mode-hook #'smartparens-mode) | |
;;(add-hook 'eshell-preoutput-filter-functions #'ansi-color-apply) | |
;;---{ File Associations }------------------------ | |
(add-to-list 'auto-mode-alist '("\\.eslintrc\\'" . json-mode)) | |
(add-to-list 'auto-mode-alist '("\\.jshintrc\\'" . json-mode)) | |
(add-to-list 'auto-mode-alist '("\\.dl\\'" . prolog-mode)) | |
(add-to-list 'auto-mode-alist '("done\\.txt\\'" . todotxt-mode)) | |
(add-to-list 'auto-mode-alist '("todo\\.txt\\'" . todotxt-mode)) | |
(add-to-list 'auto-mode-alist '("\\.html?\\'" . web-mode)) | |
(add-to-list 'auto-mode-alist '("\\.raml\\'" . yaml-mode)) | |
;;===[ KEYBINDINGS ]============================================================ | |
(defun set-global-keys () | |
(global-set-key (kbd "C-=") #'er/expand-region) | |
(global-set-key (kbd "C-;") #'iedit-mode) | |
(global-set-key (kbd "C-c a") #'align-regexp) | |
(global-set-key (kbd "C-c c b") #'comment-box) | |
(global-set-key (kbd "C-c c l") #'comment-line) | |
(global-set-key (kbd "C-c c r") #'comment-region) | |
(global-set-key (kbd "C-c c u") #'uncomment-region) | |
(global-set-key (kbd "C-c d") #'delete-trailing-whitespace) | |
(global-set-key (kbd "C-c f") #'neotree-toggle) | |
(global-set-key (kbd "C-c F") #'counsel-faces) | |
(global-set-key (kbd "C-c g") #'glasses-mode) | |
(global-set-key (kbd "C-c m") #'counsel-imenu) | |
(global-set-key (kbd "C-c M") #'imenu-list-smart-toggle) | |
(global-set-key (kbd "C-c s s") #'eshell) | |
(global-set-key (kbd "C-c s t") #'ansi-term) | |
(global-set-key (kbd "C-c t") #'counsel-load-theme) | |
(global-set-key (kbd "C-c T") #'theme-looper-enable-next-theme) | |
(global-set-key (kbd "C-c w") #'ace-select-window) | |
(global-set-key (kbd "C-c z") #'eshell-z) | |
(global-set-key (kbd "C-c <tab>") #'switch-to-next-buffer) | |
(global-set-key (kbd "C-c <backtab>") #'switch-to-prev-buffer) | |
(global-set-key (kbd "C-c C-p") #'package-list-packages) | |
(global-set-key (kbd "C-c M-r") #'rename-buffer) | |
(global-set-key (kbd "C-h c") #'helpful-command) | |
(global-set-key (kbd "C-h f") #'helpful-callable) | |
(global-set-key (kbd "C-h F") #'helpful-function) | |
(global-set-key (kbd "C-h k") #'helpful-key) | |
(global-set-key (kbd "C-h v") #'helpful-variable) | |
(global-set-key (kbd "C-s") #'swiper) | |
(global-set-key (kbd "C-x +") #'zoom) | |
;;(global-set-key (kbd "C-x b") #'counsel-ibuffer) | |
(global-set-key (kbd "C-x B") #'ibuffer-sidebar-toggle-sidebar) | |
(global-set-key (kbd "C-x C-b") #'ibuffer) | |
(global-set-key (kbd "C-x C-f") #'counsel-find-file) | |
(global-set-key (kbd "M-x") #'counsel-M-x)) | |
;;---{ Major Modes }------------------------------ | |
(defun set-major-mode-keys () | |
(with-eval-after-load 'css-mode | |
(defvar css-mode-map) | |
(define-key css-mode-map (kbd "C-c b") #'web-beautify-css) | |
(define-key css-mode-map (kbd "C-c S-c") #'counsel-colors-web)) | |
(with-eval-after-load 'dired-mode | |
(defvar dired-mode-map) | |
(define-key dired-mode-map [return] #'dired-single-buffer) | |
(define-key dired-mode-map [mouse-1] #'dired-single-buffer)) | |
;; Emacs Lisp Mode | |
(define-key emacs-lisp-mode-map (kbd "C-c S-c") #'counsel-colors-emacs) | |
(define-key emacs-lisp-mode-map (kbd "C-c C-b") #'eval-buffer) | |
(define-key emacs-lisp-mode-map (kbd "C-c C-r") #'eval-region) | |
(define-key emacs-lisp-mode-map (kbd "C-c C-c") #'compile-current-file) | |
(with-eval-after-load 'js2-mode | |
(defvar js2-mode-map) | |
(define-key js2-mode-map (kbd "C-c b") #'web-beautify-js)) | |
(with-eval-after-load 'json-mode | |
(defvar json-mode-map) | |
(define-key json-mode-map (kbd "C-c b") #'web-beautify-js)) | |
(with-eval-after-load 'sgml-mode | |
(defvar html-mode-map) | |
(define-key html-mode-map (kbd "C-c b") #'web-beautify-html)) | |
(with-eval-after-load 'web-mode | |
(defvar web-mode-map) | |
(define-key web-mode-map (kbd "C-c b") #'web-beautify-html))) | |
;;---{ SmartParens }------------------------------ | |
(defun set-smartparens-keys () | |
;; Based on: https://ebzzry.io/en/emacs-pairs/ | |
(with-eval-after-load 'smartparens | |
(sp-use-smartparens-bindings) | |
;;... Back/Forth ... | |
(define-key smartparens-mode-map (kbd "M-F") #'forward-word) | |
(define-key smartparens-mode-map (kbd "M-B") #'backward-word) | |
(define-key smartparens-mode-map (kbd "M-b") #'sp-backward-symbol) | |
(define-key smartparens-mode-map (kbd "M-f") #'sp-forward-symbol) | |
(define-key smartparens-mode-map (kbd "M-a") #'sp-beginning-of-sexp) | |
(define-key smartparens-mode-map (kbd "M-e") #'sp-end-of-sexp) | |
(define-key smartparens-mode-map (kbd "C-M-f") #'sp-forward-sexp) | |
(define-key smartparens-mode-map (kbd "C-M-b") #'sp-backward-sexp) | |
;;... S-Expression Movements ... | |
(define-key smartparens-mode-map (kbd "C-M-n") #'sp-next-sexp) | |
(define-key smartparens-mode-map (kbd "C-M-p") #'sp-previous-sexp) | |
(define-key smartparens-mode-map (kbd "C-<down>") #'sp-down-sexp) | |
(define-key smartparens-mode-map (kbd "C-<up>") #'sp-backward-up-sexp) | |
(define-key smartparens-mode-map (kbd "C-M-<down>") #'sp-backward-down-sexp) | |
(define-key smartparens-mode-map (kbd "C-M-<up>") #'sp-up-sexp) | |
;;... Wrapping/Unwrapping ... | |
(define-key smartparens-mode-map (kbd "C-c (") #'sp-wrap-round) | |
(define-key smartparens-mode-map (kbd "C-c [") #'sp-wrap-square) | |
(define-key smartparens-mode-map (kbd "C-c {") #'sp-wrap-curly) | |
(define-key smartparens-mode-map (kbd "M-[") #'sp-backward-unwrap-sexp) | |
(define-key smartparens-mode-map (kbd "M-]") #'sp-unwrap-sexp) | |
;;... Killing ... | |
(define-key smartparens-mode-map (kbd "M-D") #'kill-word) | |
(define-key smartparens-mode-map (kbd "M-d") #'sp-kill-word) | |
(define-key smartparens-mode-map (kbd "M-<backspace>") #'sp-backward-kill-word) | |
(define-key smartparens-mode-map (kbd "M-k") #'sp-kill-sexp) | |
(define-key smartparens-mode-map (kbd "M-K") #'sp-kill-hybrid-sexp))) | |
;;---{ Keybindings Hook }------------------------- | |
(defun set-custom-keybindings () | |
(set-global-keys) | |
(set-major-mode-keys) | |
(set-smartparens-keys)) | |
(add-hook 'emacs-startup-hook #'set-custom-keybindings) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment