Created
January 2, 2019 13:09
Star
You must be signed in to star a gist
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
;;; init.el --- Emacs configuration à la Home Manager. | |
;; | |
;; -*- lexical-binding: t; -*- | |
;; | |
;;; Commentary: | |
;; | |
;; A configuration generated from a Nix based configuration by | |
;; Home Manager. | |
;; | |
;;; Code: | |
;; Remember when configuration started. See bottom for rest of this. | |
;; Idea taken from http://writequit.org/org/settings.html. | |
(defconst emacs-start-time (current-time)) | |
(defun hm/reduce-gc () | |
"Reduce the frequency of garbage collection." | |
(setq gc-cons-threshold 402653184 | |
gc-cons-percentage 0.6)) | |
(defun hm/restore-gc () | |
"Restore the frequency of garbage collection." | |
(setq gc-cons-threshold 16777216 | |
gc-cons-percentage 0.1)) | |
;; Make GC more rare during init and while minibuffer is active. | |
(eval-and-compile #'hm/reduce-gc) | |
(add-hook 'minibuffer-setup-hook #'hm/reduce-gc) | |
;; But make it more regular after startup and after closing minibuffer. | |
(add-hook 'emacs-startup-hook #'hm/restore-gc) | |
(add-hook 'minibuffer-exit-hook #'hm/restore-gc) | |
;; Avoid unnecessary regexp matching while loading .el files. | |
(defvar hm/file-name-handler-alist file-name-handler-alist) | |
(setq file-name-handler-alist nil) | |
(defun hm/restore-file-name-handler-alist () | |
"Restores the file-name-handler-alist variable." | |
(setq file-name-handler-alist hm/file-name-handler-alist) | |
(makunbound 'hm/file-name-handler-alist)) | |
(add-hook 'emacs-startup-hook #'hm/restore-file-name-handler-alist) | |
(menu-bar-mode -1) ; Removes the menu-bar | |
(when window-system | |
(tool-bar-mode -1) ; Removes the toolbar in graphic editor | |
(tooltip-mode -1) ; Removes mouse hover tooltips | |
(scroll-bar-mode -1)) ; Removes the scollbar | |
(setq-default indent-tabs-mode nil | |
fill-column 80 | |
show-trailing-whitespace t) | |
(setq initial-major-mode 'org-mode ; Sets the *scratch* to org mode as default | |
initial-scratch-message nil ; Sets the *scratch* message | |
inhibit-splash-screen t ; Prevents the Emacs Startup menu | |
confirm-nonexistent-file-or-buffer t | |
save-interprogram-paste-before-kill t ; Save pastebin to kill ring | |
dired-omit-mode t ; Hides uninteresting files | |
ring-bell-function 'ignore ; Removing the beep when error | |
confirm-kill-emacs 'y-or-n-p ; Ask before closing | |
minibuffer-prompt-properties | |
'(read-only t point-entered minibuffer-avoid-prompt face minibuffer-prompt) ; Prevent Read-only warnings in prompt | |
use-dialog-box nil ; Prevent emacs from showing GUI-dialogs | |
;; Indentation | |
tab-width 2 | |
standard-indent 2 | |
tab-stop-list (number-sequence 2 120 2) ; Set the amount of spaces on identation | |
css-indent-offset 2 | |
c-basic-offset 2 | |
history-length 1000 | |
require-final-newline t ; Always end files with a newline character. | |
line-move-visual nil ; Don't want to move based on visual line. | |
;; Disable backups | |
auto-save-default nil | |
create-lockfiles nil | |
make-backup-files nil | |
backup-inhibited t | |
frame-title-format '("Emacs @ " system-name ": %b %+%+ %f") ; Sets the window title to more useful | |
sentence-end-double-space nil ; Only one space after sentence | |
echo-keystrokes 0.1 ; Show keystrokes at once in the bottom | |
system-uses-terminfo nil ; Shell mode character fix | |
password-cache-expiry (* 60 15) ; Time before asking for su pass again | |
fringes-outside-margins t | |
desktop-restore-frames nil ; for desktop-mode | |
dired-listing-switches "-aBhl --group-directories-first" | |
;; Scrolling settings | |
mouse-wheel-progressive-speed nil | |
mouse-wheel-scroll-amount '(1 ((shift) . 1)) | |
mouse-wheel-follow-mouse t | |
show-paren-delay 0) | |
(blink-cursor-mode -1); No blinking cursor | |
(mouse-avoidance-mode 'animate) ; Moves the cursor if in the way | |
(delete-selection-mode 1) ; Delete region on typing, like other editors | |
(defalias 'yes-or-no-p 'y-or-n-p) ; y for yes and n for no | |
(winner-mode 1) | |
(savehist-mode 1) | |
(global-auto-revert-mode t) | |
(global-subword-mode 1) ; Move in CamelCasing | |
(show-paren-mode) ; Highlight mathing parentese | |
(line-number-mode 1) ; show linenumber in modebar | |
(column-number-mode 1) ; show linenumber in modebar | |
(transient-mark-mode 1) | |
;; Unbind Pesky Sleep Button | |
(global-unset-key [(control z)]) | |
(global-unset-key [(control x)(control z)]) | |
(eval-when-compile | |
(require 'package) | |
(setq package-archives nil | |
package-enable-at-startup nil | |
package--init-file-ensured t) | |
(require 'use-package) | |
;; To help fixing issues during startup. | |
(setq use-package-verbose nil)) | |
;; For :diminish in (use-package). | |
(require 'diminish) | |
;; For :bind in (use-package). | |
(require 'bind-key) | |
(use-package counsel | |
:bind ( | |
("C-x C-f" . counsel-find-file) | |
("C-x C-r" . counsel-recentf) | |
("C-x C-y" . counsel-yank-pop) | |
("M-x" . counsel-M-x) | |
) | |
:diminish (counsel-mode)) | |
(use-package evil | |
:config | |
(evil-mode 1) | |
:init | |
(setq evil-want-integration t) | |
(setq evil-want-keybinding nil) | |
) | |
(use-package evil-collection | |
:after (evil) | |
:config | |
(evil-collection-init)) | |
(use-package evil-commentary | |
:config | |
(evil-commentary-mode)) | |
(use-package evil-surround | |
:config | |
(global-evil-surround-mode 1)) | |
(use-package flycheck | |
:commands (global-flycheck-mode) | |
:config | |
;; Only check buffer when mode is enabled or buffer is saved. | |
(setq flycheck-check-syntax-automatically '(mode-enabled save)) | |
;; Enable flycheck in all eligible buffers. | |
(global-flycheck-mode) | |
) | |
(use-package flycheck-haskell | |
:hook (flycheck-mode . flycheck-haskell-setup)) | |
(use-package gruvbox-theme | |
:config | |
;; Only use theme if GUI | |
(if (display-graphic-p) | |
(load-theme 'gruvbox-light-soft t)) | |
) | |
(use-package haskell-mode | |
:hook (haskell-mode | |
. (lambda () | |
(subword-mode +1) | |
(interactive-haskell-mode +1) | |
(haskell-doc-mode +1) | |
(haskell-indentation-mode +1) | |
(haskell-decl-scan-mode +1))) | |
:mode ("\\.hs\\'" . haskell-mode) | |
:mode ("\\.hsc\\'" . haskell-mode) | |
:mode ("\\.c2hs\\'" . haskell-mode) | |
:mode ("\\.cpphs\\'" . haskell-mode) | |
:mode ("\\.lhs\\'" . literate-haskell-mode) | |
:config | |
(require 'haskell) | |
(require 'haskell-doc) | |
(setq haskell-process-auto-import-loaded-modules t | |
haskell-process-suggest-remove-import-lines t | |
haskell-process-log t | |
haskell-tags-on-save t | |
haskell-notify-p t) | |
(setq haskell-process-args-cabal-repl | |
'("--ghc-options=+RTS -M500m -RTS -ferror-spans -fshow-loaded-modules")) | |
) | |
(use-package highlight-symbol | |
:diminish (highlight-symbol-mode) | |
:config | |
(add-hook 'prog-mode-hook 'highlight-symbol-mode) | |
(setq highlight-symbol-idle-delay .2 | |
highlight-symbol-highlight-single-occurrence nil)); | |
) | |
(use-package ivy | |
:diminish (ivy-mode) | |
:config | |
(setq ivy-height 15) | |
(ivy-mode 1) | |
) | |
(use-package magit | |
:bind ( | |
("C-x g s" . magit-status) | |
) | |
:config | |
(setq magit-completing-read-function 'ivy-completing-read | |
magit-log-section-arguments '("--graph" "--color" "--decorate" "-n256")) | |
(add-to-list 'git-commit-style-convention-checks | |
'overlong-summary-line) | |
) | |
(use-package nix-mode | |
:mode "\\.nix\\'") | |
(use-package saveplace | |
:config | |
(setq-default save-place t) | |
(setq save-place-file (locate-user-emacs-file "places")) | |
) | |
(use-package swiper | |
:bind ( | |
("C-s" . swiper) | |
)) | |
(use-package systemd | |
:defer t) | |
(use-package uniquify | |
:config | |
(setq uniquify-buffer-name-style 'post-forward) | |
) | |
(use-package which-key | |
:commands (which-key-mode) | |
:defer 2 | |
:diminish (which-key-mode) | |
:config | |
(which-key-mode)) | |
;; Make a note of how long the configuration part of the start took. | |
(let ((elapsed (float-time (time-subtract (current-time) | |
emacs-start-time)))) | |
(message "Loading settings...done (%.3fs)" elapsed)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment