dots-of-war/files/.emacs.d/config.org
2020-11-08 22:29:46 +01:00

9.1 KiB

Emacs Config

General Settings

Typing :ensure t everywhere is very bothersome so I'd rather not do that.

  (require 'use-package-ensure)
  (setq use-package-always-ensure t)

Don't create all the custom things.

  (defconst custom-file "/dev/null")

I don't want my Emacs to create loads of backup files, swap files, etc.

  (setq make-backup-files nil)
  (setq auto-save-default nil)

Nor do I need all the (Windows 2000-esque) UI.

  (scroll-bar-mode -1)
  (tool-bar-mode -1)
  (tooltip-mode -1)
  (menu-bar-mode -1)

When I fire up Emacs I want to be greeted with an empty *scratch* buffer, not the weird GNU screen.

  (setq inhibit-splash-screen t
        initial-scratch-message "")

The whole yes or no prompt takes too much time to type out. y and n is much better.

  (defalias 'yes-or-no-p 'y-or-n-p)

UTF-8 is good and should be the default for everything.

  (setq locale-coding-system 'utf-8)
  (set-terminal-coding-system 'utf-8)
  (set-keyboard-coding-system 'utf-8)
  (set-selection-coding-system 'utf-8)
  (prefer-coding-system 'utf-8)

Which key makes Emacs self documenting.

  (use-package which-key
    :config
	(setq which-key-idle-delay 0.25)
    (which-key-mode 1))

Restart emacs

Restarting emacs from within emacs!

(use-package restart-emacs
	:config
	(setq restart-emacs-restore-frames t))

disable clipboard whatever

Clipboard shit is fucked, so this is necessary to unfuck.

	(setq x-select-enable-clipboard-manager nil)

Store recent files

(recentf-mode 1)
(setq recentf-max-menu-items 25)
(setq recentf-max-saved-items 25)
;; (run-at-time nil (* 5 60) 'recentf-save-list)

VTerm

(use-package vterm)

Looks

tab width

  (setq-default tab-width 4)

Font

I prefer Source Code Pro for now.

  (add-to-list 'default-frame-alist
               '(font . "xos4 Terminus"))

COMMENT Line numbers

  (use-package linum-relative
    :config
    (setq linum-relative-backend 'display-line-numbers-mode)
    (linum-relative-global-mode 1))

Color Theme

  (use-package gruvbox-theme
    :config
    (load-theme 'gruvbox-dark-medium t))

Beacon

Highlights the cursor each time I switch windows.

  (use-package beacon
    :config
    (beacon-mode 1))

Fringe

Ugly.

  (fringe-mode '(10 . 10))

COMMENT Mode-line

  (use-package telephone-line
	  :config
	  (setq telephone-line-lhs
			  '((evil   . (telephone-line-evil-tag-segment))
			  (blue . (telephone-line-vc-segment
						  telephone-line-process-segment))
			  (nil . (telephone-line-buffer-segment))))
	  (setq telephone-line-rhs
			  '((nil    . (telephone-line-misc-info-segment))
			  (accent . (telephone-line-major-mode-segment))
			  (evil   . (telephone-line-airline-position-segment))))
	  (setq telephone-line-primary-left-separator 'telephone-line-cubed-left
			telephone-line-secondary-left-separator 'telephone-line-cubed-hollow-left
			telephone-line-primary-right-separator 'telephone-line-cubed-right
			telephone-line-secondary-right-separator 'telephone-line-cubed-hollow-right)
	  (setq telephone-line-height 24
			telephone-line-evil-use-short-tag t)
	  (telephone-line-mode t))

doom-modeline

  (use-package doom-modeline
	:config
	(setq doom-modeline-icon (display-graphic-p))
	(setq doom-modeline-env-version t)
	(setq doom-modeline-project-detection 'project)
	(setq doom-modeline-height 0)
	(doom-modeline-mode t))

TODO NAME THIS

Ivy

Ivy for completing stuff, etc. is huge.

  (use-package counsel
    :config
    (ivy-mode)
 (setq ivy-re-builders-alist '((t . ivy--regex-fuzzy)))
 (setq ivy-initial-inputs-alist nil)

    :bind
    ("C-s" . swiper)
    ("M-x". counsel-M-x))

flx

Flx does fancy fuzzy matching with good sorting

  (use-package flx
 :config
 )

Projectile

(use-package projectile
	:config
	(projectile-mode t))
(use-package counsel-projectile
	:after projectile counsel
	:config)

fix the naming for which-key

(add-to-list 'which-key-replacement-alist
	'((nil . "projectile-\\([[:alnum:]-]+\\)") . (nil . "\\1")))

general.el

  (use-package general
	:config
	(general-evil-setup)
	(general-def
	  :states '(normal motion)
	  "SPC" nil)

	(general-create-definer elk-noleader-def
	  :states '(normal motion)
	  :keymaps 'override)
	(general-create-definer elk-leader-def
	  :prefix "SPC"
	  :states '(normal motion)
	  :keymaps 'override)
	(general-create-definer elk-local-leader-def
	  :prefix "SPC m"
	  :states '(normal motion)
	  :keymaps 'local)

	(elk-leader-def
	  "a" 'org-agenda
	  "s" 'org-store-link
	  "t" '((lambda () (interactive) (org-capture nil "t")) :wk "org-capture whatever")
	  "f" '(counsel-find-file :wk "open a file")
	  "1" 'delete-other-windows
	  "0" 'delete-window
	  "p" '(:keymap projectile-command-map :wk "Project")
	  )

	(which-key-add-key-based-replacements "SPC y" "Emacs stuff")
	(elk-leader-def
	  :prefix "SPC y"
	  "c" '((lambda () (interactive) (find-file "~/.emacs.d/config.org")) :wk "open config.org")
	  "r" '((lambda () (interactive) (load-file "~/.emacs.d/init.el")) :wk "reload config.org")))

Window management

  (which-key-add-key-based-replacements "SPC b" "Window management")
  (elk-leader-def
	:prefix "SPC b"
	"c" '(delete-window :wk "close window")
	"f" '(counsel-buffer-or-recentf :wk "Switch to file")
	"b" '(counsel-switch-buffer :wk "Switch buffer")
	"o" '(counsel-switch-buffer-other-window :wk "Switch buffer in other window")
	"d" '(kill-buffer :wk "close buffer")
	"s" '(split-window-below :wk "h-split")
	"v" '(split-window-right :wk "v-split"))

Editing

evil-mode

Emacs is lacks a good editor.

  (use-package evil
    :init
    (setq evil-want-keybinding nil)
	(setq evil-want-C-u-scroll t)
	(setq evil-want-fine-undo 'fine)
	(setq evil-undo-system 'undo-tree)
    :config
    (evil-mode 1))

evil-org-mode

  (use-package evil-org
    :after org
    :config
    (add-hook 'org-mode-hook 'evil-org-mode)
    (add-hook 'evil-org-mode-hook
	   (lambda ()
	 (evil-org-set-key-theme)))
    (require 'evil-org-agenda)
    (evil-org-agenda-set-keys))

evil-collection

Keybinds for common modes. Makes evil work everywhere.

(use-package evil-collection
:after evil
:config
(evil-collection-init))

evil-surround

(use-package evil-surround
:ensure t
:after evil
:config
(global-evil-surround-mode t))

Undo-tree

Undo tree is based.

  (use-package undo-tree
    :init
    :config
	(global-undo-tree-mode t)
	(setq undo-tree-auto-save-history t))

ace-jump

  (use-package ace-jump-mode)
  (elk-leader-def "x" 'ace-jump-mode)

Multicursor

Install the package

  (use-package evil-mc
	:config
	(evil-mc-mode 1))

And set up some keybinds!

  (which-key-add-key-based-replacements "SPC d" "Multicursor")
  (elk-leader-def
	  :prefix "SPC d"
	  "j" '(evil-mc-make-cursor-move-next-line :wk "cursor below")
	  "u" '(evil-mc-undo-last-added-cursor  :wk "undo cursor")
	  "d" '(evil-mc-undo-all-cursors  :wk "remove all cursors")
	  "n" '(evil-mc-make-and-goto-next-match  :wk "next match")
	  "m" '(evil-mc-skip-and-goto-next-match  :wk "skip and next match")
	  "s" '(evil-mc-make-cursor-in-visual-selection-beg  :wk "cursor at selection"))

Code stuff

Rainbow everything!

because rainbows are fancy!

  (use-package rainbow-delimiters
	:init
	:config
	(rainbow-delimiters-mode t))

  (use-package rainbow-blocks
	:init
	:config
	(rainbow-blocks-mode t))

Nerdcommenter

  (use-package evil-nerd-commenter)
  (which-key-add-key-based-replacements "SPC c" "Commenting")
  (elk-leader-def
	:prefix "SPC c"
	"SPC" '(evilnc-comment-or-uncomment-lines :wk "toggle comment")
	"c" '(evilnc-copy-and-comment-lines :wk "copy and comment"))

Git integration

Diff-hl gitgutter

  (use-package diff-hl
	:init
	:config
	(diff-hl-mode t))

Magit

  (use-package magit
	:init
	:config
	(rainbow-delimiters-mode t))
  (use-package evil-magit
	:init
	:config
	(rainbow-delimiters-mode t))

  (which-key-add-key-based-replacements "SPC g" "Git shit")
  (elk-leader-def
	:prefix "SPC g"
	"s" '(magit-status :wk "status"))