/emacs.d

Primary LanguageEmacs Lisp

Emacs Configuration

Interface

Disable some parts of the UI.

(menu-bar-mode -1)
(tool-bar-mode -1)
(scroll-bar-mode -1)
(blink-cursor-mode -1)

Change some of the defaults.

(setq-default inhibit-splash-screen t
              initial-scratch-message nil
              make-backup-files nil
              select-enable-clipboard t
              select-enable-primary t
              indent-tabs-mode nil
              gc-cons-threshold 100000000
              read-process-output-max (* 1024 1024))

;; prefer vertical splits if there is enough space
(setq split-height-threshold nil
      split-width-threshold 160)

;; UTF-8
(prefer-coding-system 'utf-8)

(setq backup-directory-alist
      `((".*" . ,temporary-file-directory)))
(setq auto-save-file-name-transforms
      `((".*" ,temporary-file-directory t)))

;; and tell emacs to play nice with encoding
(define-coding-system-alias 'UTF-8 'utf-8)
(define-coding-system-alias 'utf8 'utf-8)

;; delete trailing whitespace in all modes
(add-hook 'before-save-hook #'delete-trailing-whitespace)

;; Enable S-{left, right, up, down} to switch window focus
(windmove-default-keybindings)
;; Make windmove work in org-mode:
(add-hook 'org-shiftup-final-hook 'windmove-up)
(add-hook 'org-shiftleft-final-hook 'windmove-left)
(add-hook 'org-shiftdown-final-hook 'windmove-down)
(add-hook 'org-shiftright-final-hook 'windmove-right)

Change the behaviour of scrolling.

(setq scroll-preserve-screen-position t ;;keep cursor at same position when scrolling
      mouse-wheel-scroll-amount '(1 ((shift) . 1)) ;; one line at a time
      mouse-wheel-progressive-speed nil ;; don't accelerate scrolling
      mouse-wheel-follow-mouse 't ;; scroll window under mouse
      scroll-step 1 ;; keyboard scroll one line at a time
      scroll-conservatively 10000
      scroll-margin 3)

Fonts

(add-to-list 'default-frame-alist '(font . "Share Tech Mono-11"))
(set-face-attribute 'default nil :font "Share Tech Mono-11")

Customize

Put all the customize settings into its own file.

(setq custom-file
      (expand-file-name "custom.el" user-emacs-directory))
(load custom-file 'noerror)

Theme

(use-package nord-theme
  :ensure t
  :config (load-theme 'nord t))

Parentheses

(use-package rainbow-delimiters
  :ensure t
  :init (add-hook 'prog-mode-hook 'rainbow-delimiters-mode))

Darkroom

(use-package darkroom
  :ensure t)

Evil

(use-package general
  :ensure t
  :config
  (general-evil-setup)
  (general-create-definer my-leader-def
    :states '(normal motion visual)
    :keymaps 'override
    :prefix "SPC")
  (my-leader-def
    "SPC" 'execute-extended-command
    "b" 'consult-buffer
    "s" 'consult-line
    "ff" 'find-file
    "cd" 'cd
    "n" 'flymake-goto-next-error
    "p" 'flymake-goto-prev-error))

(use-package evil
  :ensure t
  :init
  (setq evil-want-C-u-scroll t)
  (setq evil-want-keybinding nil)
  (setq evil-undo-system 'undo-redo)
  :config (progn
	      (evil-mode 1)
	      (defalias #'forward-evil-word #'forward-evil-symbol)))

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

(use-package evil-org
  :ensure t
  :after org
  :config
  (add-hook 'org-mode-hook 'evil-org-mode)
  (add-hook 'evil-org-mode-hook
            (lambda ()
              (evil-org-set-key-theme))))

Editing

Git

(use-package magit
  :ensure t
  :bind (("C-c m" . magit-status)))

Projects

(use-package project
  :bind ("C-x f" . project-find-file))

Completion and filtering

(use-package corfu
  :ensure t
  :custom
  (corfu-auto t)
  (corfu-auto-delay 0)
  (corfu-auto-prefix 2)
  (corfu-quit-no-match nil)
  (corfu-preselect 'prompt)
  :init (global-corfu-mode))

(use-package corfu-terminal
  :ensure t
  :unless (display-graphic-p)
  :after corfu
  :init (corfu-terminal-mode))

(use-package eglot
  :ensure t
  :hook ((rust-mode . eglot-ensure)))
(use-package vertico
  :ensure t
  :init (vertico-mode)
  :custom
  (vertico-resize t)
  (vertico-cycle t))

(use-package savehist
  :ensure t
  :init (savehist-mode))

(use-package orderless
  :ensure t
  :custom
  (completion-styles '(orderless basic))
  (completion-category-defaults nil)
  (completion-category-overrides '((file (styles partial-completion)))))

(use-package consult
  :ensure t)

(use-package marginalia
  :ensure t
  :init (marginalia-mode))

Languages

Support for different programming languages.

Rust

(use-package rust-mode
  :ensure t)

Elixir

(use-package elixir-mode
  :ensure t)

(use-package alchemist
  :ensure t
  :disabled
  :config (setq alchemist-mix-test-default-options "--no-start"))

Org

(use-package org
  :ensure t
  :init (setq org-agenda-window-setup 'current-window
              org-src-fontify-natively t
              org-src-tab-acts-natively t
              org-src-window-setup 'current-window
              org-agenda-files '("~/org/gtd.org")))

Markdown

(use-package markdown-mode
  :ensure t
  :mode (("README\\.md\\'" . gfm-mode)
         ("\\.md\\'" . markdown-mode)
         ("\\.markdown\\'" . markdown-mode)))

Web

(use-package web-mode
  :ensure t
  :mode ("\\.html?\\'" "\\.svelte\\'")
  :config (setq web-mode-markup-indent-offset 2
                web-mode-code-indent-offset 2
                web-mode-css-indent-offset 2))

LaTeX

(use-package tex-site
  :ensure auctex
  :config (setq TeX-PDF-mode t
                ;TeX-command-force "LaTeX"
                TeX-view-program-list '(("PDF Viewer" "zathura %o"))))

Python

(use-package python-black
  :ensure t
  :demand t
  :after python
  :hook (python-mode . python-black-on-save-mode))