Created
January 3, 2019 11:32
-
-
Save Jomik/4e6611727ccfe7e74a444a8f458882e0 to your computer and use it in GitHub Desktop.
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; -*- | |
;;; Emacs configuration à la Home Manager. | |
;; | |
;; | |
;;; 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 | |
(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 | |
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 | |
standard-indent 2 | |
tab-width 2 | |
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) | |
(electric-indent-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) | |
;; For :general in (use-package). | |
(require 'general) | |
(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 dotenv-mode | |
:mode "\\.env\\..*\\") | |
(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 | |
:diminish (evil-commentary-mode) | |
:config | |
(evil-commentary-mode)) | |
(use-package evil-goggles | |
:config | |
(evil-goggles-mode)) | |
(use-package evil-surround | |
:config | |
(global-evil-surround-mode 1)) | |
(use-package evil-vimish-fold | |
:after (vimish-fold) | |
:diminish (evil-vimish-fold-mode) | |
:config | |
(evil-vimish-fold-mode 1)) | |
(use-package fish-mode | |
:mode "\\.fish\\'") | |
(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 general | |
:config | |
(general-evil-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\\'" | |
:mode "\\.hsc\\'" | |
:mode "\\.c2hs\\'" | |
:mode "\\.cpphs\\'" | |
: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 hydra | |
:config | |
(setq-default hydra-default-hint nil) | |
(defhydra hydra-leader nil | |
"Leader" | |
("q" nil) | |
("c" hydra-flycheck/body "flycheck" :color blue) | |
("f" hydra-fold/body "fold" :color blue)) | |
(defhydra hydra-flycheck (:color pink) | |
" | |
^ | |
^Flycheck^ ^Errors^ ^Checker^ | |
^────────^──────────^──────^────────────^───────^─────────── | |
_q_ quit _p_ previous _?_ describe | |
_m_ manual _n_ next _d_ disable | |
_v_ verify setup _f_ check _s_ select | |
^^ _l_ list ^^ | |
^^ ^^ ^^ | |
" | |
("q" nil) | |
("p" flycheck-previous-error) | |
("n" flycheck-next-error) | |
("?" flycheck-describe-checker :color blue) | |
("d" flycheck-disable-checker :color blue) | |
("f" flycheck-buffer) | |
("l" flycheck-list-errors :color blue) | |
("m" flycheck-manual :color blue) | |
("s" flycheck-select-checker :color blue) | |
("v" flycheck-verify-setup :color blue)) | |
(defhydra hydra-fold (:color pink) | |
" | |
^ | |
^Fold^ ^Do^ ^Jump^ ^Toggle^ | |
^────^──────────────^──^────────────────^────^──────────────^──────^──────────── | |
_q_ quit _f_ fold _p_ previous _t_ current | |
^^ _k_ kill _n_ next _T_ all | |
^^ _K_ kill all ^^ ^^ | |
^^ ^^ ^^ ^^ | |
" | |
("q" nil) | |
("t" vimish-fold-toggle) | |
("T" vimish-fold-toggle-all) | |
("p" vimish-fold-previous-fold) | |
("n" vimish-fold-next-fold) | |
("f" vimish-fold) | |
("k" vimish-fold-delete) | |
("K" vimish-fold-delete-all)) | |
:general | |
(:states '(normal visual) | |
(kbd "SPC") 'hydra-leader/body) | |
) | |
(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\\'" | |
:config | |
(setq nix-indent-function 'nix-indent-line)) | |
(use-package projectile | |
:commands (projectile-mode) | |
:diminish (projectile-mode) | |
:config | |
(setq projectile-enable-caching t | |
projectile-completion-system 'ivy) | |
(projectile-mode 1) | |
) | |
(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 vimish-fold) | |
(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