Skip to content

Latest commit

 

History

History
872 lines (763 loc) · 22.4 KB

emacs.org

File metadata and controls

872 lines (763 loc) · 22.4 KB

Emacs

The extensible, customizable, self-documenting real-time display editor

General

Hide toolbars.

(menu-bar-mode -1)
(tool-bar-mode -1)
(toggle-scroll-bar -1)
(add-to-list 'default-frame-alist
             '(vertical-scroll-bars . nil))

Fix problem with downloading undo-tree. undo-tree is required by Evil and other packages.

;(setq gnutls-algorithm-priority "NORMAL:-VERS-TLS1.3")

Load package manager, add the Melpa package registry.

(require 'package)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
(add-to-list 'package-archives '("melpa-stable" . "https://stable.melpa.org/packages/") t)
(add-to-list 'package-archives '("org" . "https://orgmode.org/elpa/") t)
;(setq package-check-signature nil)
(package-initialize)

Automatically update the list of packages, only if there is no package list already:

(when (not package-archive-contents)
  (package-refresh-contents))

Bootstrap use-package.

(unless (package-installed-p 'use-package)
  (package-refresh-contents)
  (package-install 'use-package))
(require 'use-package)

Hide default welcome screen.

(setq inhibit-startup-screen t)

Install package automatically if not already present on your system.

(setq use-package-always-ensure t)

Use General for keybindings:

(use-package general)

Disable native-comp warnings:

(setq native-comp-async-report-warnings-errors nil)

Setup font.

(add-to-list 'default-frame-alist
  '(font . "<<font>>"))
(set-face-attribute 'default t :font "<<font>>" :height 100)

Display relative line number

(setq-default display-line-numbers-type 'relative)
(global-display-line-numbers-mode t)

Disable cursor blinking:

(blink-cursor-mode 0)

Show matching pairs of parentheses

(show-paren-mode 1)

Use dot and single space to end the sentence:

(setq sentence-end-double-space nil)

Highlight trailing whitespaces

(defun my-show-trailing-ws ()
  "Show trailing whitespace in the current buffer, unless it is read-only."
  (setq-local show-trailing-whitespace (not buffer-read-only)))

(add-hook 'post-command-hook 'my-show-trailing-ws)

Draw tabs with the same color as trailing whitespace

(add-hook 'font-lock-mode-hook
          (lambda ()
            (font-lock-add-keywords nil
              '(("\t" 0 'trailing-whitespace prepend)))))

Save typing one or two characters:

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

Automatically insert newlines in text modes:

(add-hook 'text-mode-hook 'auto-fill-mode)

Highlight invalid spelling

(setq ispell-program-name "aspell")
(setq ispell-list-command "--list")

(add-hook 'text-mode-hook 'flyspell-mode)
(add-hook 'prog-mode-hook 'flyspell-prog-mode)

Switch the spell checker based on the identified language

(use-package guess-language
  :custom
    (guess-language-languages '(en cs))
    (guess-language-min-paragraph-length 35)
  :config (add-hook 'text-mode-hook (lambda () (guess-language-mode 1)))
)

Write backups to ~/.emacs.d/backup/

(setq backup-directory-alist '(("." . "~/.emacs.d/backup"))
      backup-by-copying      t  ; Don't de-link hard links
      version-control        t  ; Use version numbers on backups
      delete-old-versions    t  ; Automatically delete excess backups
      kept-new-versions      20 ; how many of the newest versions to keep
      kept-old-versions      5) ; and how many of the old

Org

Set org-mode keybindings:

(use-package org
  :general
  ("C-c a" '(my-org-agenda :no-autoload t))
  :preface
  (defun my-org-agenda ()
    (interactive)
    (progn (org-agenda 1 "n")
      (org-agenda-fortnight-view)))
)

Use hard indentation:

(setq org-adapt-indentation t)

Enable org-habit module:

(add-to-list 'org-modules 'org-habit t)

Show agenda always in the current window:

(setq org-agenda-window-setup "current-window")

Allow to evaluate source blocks from org-mode.

(org-babel-do-load-languages
 'org-babel-load-languages '(
    (dot . t)
    (R . t)
    (plantuml . t)
  )
)

Highlight LaTeX commands inside Org Mode.

(setq org-highlight-latex-and-related '(latex script entities))

Change org-mode exporting process to pdf. Needed for bibtex support.

(setq org-latex-pdf-process
      '("latexmk -pdflatex='pdflatex -shell-escape -interaction nonstopmode' -pdf -bibtex -f %f"))

Run org-mode code snippets without confirmation.

(setq org-confirm-babel-evaluate nil)

Include my Org files into the agenda

(setq org-agenda-files '("~/Documents/personal/notes"))

Allow to use alphabetical characters in ordered lists:

(setq org-list-allow-alphabetical t)

Do not indent tags:

(setq org-tags-column 0)

Do not indent properties:

(setq org-property-format "%s %s")

Calendar for org-mode

;(use-package calfw-org)

Hide leading stars

;(setq org-hide-leading-stars t)

Make headings bigger

;(custom-set-faces
;  '(org-level-1 ((t (:height 1.7))))
;  '(org-level-2 ((t (:height 1.6))))
;  '(org-level-3 ((t (:height 1.5))))
;  '(org-level-4 ((t (:height 1.4))))
;)

Make org-mode stars a little more super

;(use-package org-superstar
;  :custom
;    (org-superstar-headline-bullets-list '("◉" "◎" "◈" "◇"))
;  :config
;  (add-hook 'org-mode-hook
;    (lambda () (org-superstar-mode 1)))
;)

Enable encryption using org-crypt:

(require 'org-crypt)
(require 'epa-file)
(epa-file-enable)
(org-crypt-use-before-save-magic)
(setq org-tags-exclude-from-inheritance (quote ("crypt")))
(setq org-crypt-key "<<crypt_key>>")

This makes gpg ask gpg-agent instead of emacs:

(setf epa-pinentry-mode 'ask)

Packages

Use dashboard as a welcome screen.

(use-package dashboard
  :custom
  (dashboard-set-heading-icons t)
  (dashboard-set-file-icons t)
  (dashboard-startup-banner 3)
  (dashboard-page-separator "\n\n\n")
  (dashboard-center-content t)
  (dashboard-items '((recents  . 5)
                     (bookmarks . 5)
                     (projects . 5)
                     (agenda . 5)
                     (registers . 5)))
  (initial-buffer-choice (lambda () (switch-to-buffer "*dashboard*")))
  :config
  (dashboard-setup-startup-hook)
)

Minor mode that hides the mode-line

(use-package hide-mode-line)

Use Unix Pass within auth-source.

(use-package auth-source-pass
  :init (auth-source-pass-enable))

Package to display a terminal in an Emacs buffer.

;(use-package vterm
;  :custom (vterm-shell "fish"))

Use editorconfig.

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

Alows managing window configurations similary to tiling WMs.

;(use-package eyebrowse
;  :config
;  (eyebrowse-mode)
;  (eyebrowse-setup-opinionated-keys))

Support for vim keybindings.

(use-package evil
  :defer .1
  :init
  (setq evil-want-keybinding nil)
  :config
  ;(global-undo-tree-mode)
  ;(evil-set-undo-system 'undo-tree)
  (evil-mode))

Collection of Evil bindings

(use-package evil-collection
  :after evil
  :custom (evil-collection-company-use-tng nil)
  :config
  (evil-collection-init))

Customizable key sequence to escape from insert state and everything else in Emacs.

(use-package evil-escape
  :custom
  (evil-escape-unordered-key-sequence t)
  :config
  (evil-escape-mode))

Tool for minibuffer completion.

(use-package ivy
  :defer .1
  :custom
  (ivy-use-virtual-buffers t)
  (ivy-count-format "%d/%d ")
  :config
  (ivy-mode))

Counsel, a collection of Ivy-enhanced versions of common Emacs commands.

(use-package counsel
  :after ivy
  :config (counsel-mode))

More friendly interface for ivy.

(use-package ivy-rich
  :after ivy
  :custom
  (ivy-rich-path-style 'abbrev)
  :config
  (ivy-rich-mode 1))

Better experience with icons for ivy

(use-package all-the-icons-ivy-rich
  :init (all-the-icons-ivy-rich-mode 1))

Package that displays available keybindings in popup.

(use-package which-key
  :defer 0.2
  :diminish
  :config (which-key-mode))

Set up email client:

(use-package notmuch
  :config
  (setq notmuch-fcc-dirs '(("<<email>>" . "personal/Sent")))
  (setq notmuch-show-logo nil)
  (setq +notmuch-sync-backend 'mbsync)

  ;; use msmtp
  (setq message-send-mail-function 'message-send-mail-with-sendmail)
  (setq sendmail-program "/usr/bin/msmtp")
  (setq mail-specify-envelope-from t)
  (setq mail-envelope-from 'header)
  (setq message-sendmail-envelope-from 'header)

  ;; set email directories
  (setq message-auto-save-directory "~/.mail/personal/Draft")
  (setq message-kill-buffer-on-exit t)
  (setq message-directory "~/.mail/personal/Sent")

  ;; set my mail address
  (setq user-mail-address "<<email>>")
)

Git interface.

(use-package magit)

Package for highlighting uncommitted changes.

(use-package diff-hl
  :demand t
  :hook (magit-post-refresh diff-hl-magit-post-refresh)
  :config (global-diff-hl-mode))

Package for TidalCycles integration

(use-package tidal
  :config (setq tidal-boot-script-path "~/.config/tidal/BootTidal.hs")
)

Use mode that comes with supercollider package (on Arch Linux)

;(require 'sclang)

Set path to TeX Live (use Flatpak SDK)

(setenv "PATH" "/usr/lib/sdk/texlive/bin/x86_64-linux/:$PATH" t)

LaTeX package

(use-package tex
  :defer t
  :ensure auctex
  :config
  (TeX-source-correlate-mode)
  (add-to-list 'TeX-view-program-selection
               '(output-pdf "Zathura")))

Completion back-ends for for math unicode symbols and latex tags

(use-package company-math
  :config
  (defun my-company-latex-setup ()
    (setq-local company-backends
      (append '((company-math-symbols-latex company-latex-commands))
        company-backends))
    (company-mode 1)
  )
  (add-hook 'TeX-mode-hook 'my-company-latex-setup)
  (add-hook 'org-mode-hook 'my-company-latex-setup)
)

YAML support:

(use-package yaml-mode)

Markdown support:

(use-package markdown-mode
  :commands (markdown-mode gfm-mode)
  :mode (("README\\.md\\'" . gfm-mode)
         ("\\.md\\'" . markdown-mode)
         ("\\.markdown\\'" . markdown-mode))
  :init (setq markdown-command "multimarkdown"))

PlantUML support:

(use-package plantuml-mode
  :custom (org-plantuml-jar-path (expand-file-name "/usr/share/java/plantuml/plantuml.jar"))
)

Cucumber support:

(use-package feature-mode)

Syntax highlighting for systemd Files

(use-package systemd)

Project Interaction Library

(use-package projectile
  :config
  (define-key projectile-mode-map (kbd "M-p") 'projectile-command-map)
  (projectile-mode +1))

Ivy UI for Projectile

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

On the fly syntax checking for GNU Emacs

(use-package flycheck
  :init (global-flycheck-mode))

Text completion framework

(use-package company)

Emacs client/library for the Language Server Protocol

(use-package lsp-mode
  :hook (python-mode . lsp)
  :hook (java-mode . lsp)
  :commands lsp)

(use-package lsp-ui
  :custom
  (lsp-ui-sideline-enable nil)
  (lsp-ui-doc-delay 1.5)
  :commands lsp-ui-mode)

Debug adapter protocol

(use-package dap-mode
  :after lsp-mode
  :config
  (dap-mode t)
  (dap-ui-mode t)
  (require 'dap-python)
)

LSP for Java

(use-package hydra)
(use-package lsp-java :after lsp
  :config (add-hook 'java-mode-hook 'lsp)
          (require 'dap-java))

A template system

(use-package yasnippet-snippets)
(use-package yasnippet
  :config (yas-global-mode 1))

Groovy syntax highlighting

(use-package groovy-mode)

Rust syntax highlighting

(use-package rust-mode)

LUA syntax highlighting

(use-package lua-mode)

Haskell syntax highlighting

(use-package haskell-mode
  :custom (haskell-interactive-popup-errors nil)
  :config (evil-set-initial-state 'haskell-interactive-mode 'emacs)
)

Set up Emacs for R

(add-to-list 'package-pinned-packages '(ess . "melpa-stable") t)
(use-package ess)

Evil for 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))

Treemacs

(use-package treemacs
  :config (treemacs-follow-mode t)
  :bind ("C-=" . treemacs)
  :hook (treemacs-mode . hide-mode-line-mode))

(use-package treemacs-evil
  :after treemacs evil)

(use-package treemacs-projectile
  :after treemacs projectile)

(use-package lsp-treemacs
  :after treemacs lsp)

(use-package kaolin-themes
  :config
  (require 'kaolin-themes-treemacs))

Highlight indentation

(use-package highlight-indent-guides
  :custom
  (highlight-indent-guides-method 'character)
  (highlight-indent-guides-character ?\|)
  (highlight-indent-guides-responsive 'top)
  :config
  (add-hook 'prog-mode-hook 'highlight-indent-guides-mode))

Lightweight syntax highlighting improvement for numbers and escape sequences (e.g. \n, \t):

(use-package highlight-numbers
 :hook (prog-mode . highlight-numbers-mode))

(use-package highlight-escape-sequences
 :hook (prog-mode . hes-mode))

Icon fonts for Emacs. Needs manual installation of the fonts: M-x all-the-icons-install-fonts

(use-package all-the-icons)

Better mode-line

(use-package doom-modeline
  :init (doom-modeline-mode 1)
  :custom (doom-modeline-icon t))

Tab support

(use-package centaur-tabs
  :demand
  :custom
  (centaur-tabs-set-icons t)
  (centaur-tabs-gray-out-icons 'buffer)
  (centaur-tabs-set-close-button nil)
  (centaur-tabs-height 20)
  :bind
    (:map evil-normal-state-map
      ("g t" . centaur-tabs-forward)
      ("g T" . centaur-tabs-backward))
  :config
  (centaur-tabs-headline-match)
  (centaur-tabs-change-fonts "<<font>>" 100)
  (centaur-tabs-mode t))

Pop-up shell

;(use-package shell-pop
;  :hook (
;  (shell-pop-in-after . hide-mode-line-mode)
;  (shell-pop-in-after . centaur-tabs-local-mode))
;  :bind ("C-:" . shell-pop)
;  :custom
;  (shell-pop-window-size 25)
;  (shell-pop-shell-type '("vterm" "*vterm*" (lambda nil (vterm))))
;)

Visually distinguish active windows

;(use-package dimmer
;  :custom
;  (dimmer-fraction 0.3)
;  (dimmer-watch-frame-focus-events nil)
;  :config
;  (dimmer-configure-which-key)
;  (dimmer-mode t))

Display visual hint on evil edit operations

(use-package evil-goggles
  :config (evil-goggles-mode))

Scroll bar

(use-package yascroll
  :config
  (progn
    (global-yascroll-bar-mode 1)
    (set-face-attribute 'yascroll:thumb-fringe t
      :background "#<<base03>>"
      :foreground "#<<base03>>")
  ))

Add support for Grammarly

;(use-package flycheck-grammarly)

Distraction-free words correction with flyspell via Ivy.

(use-package flyspell-correct-ivy
  :bind ("C-;" . flyspell-correct-wrapper)
  :init
  (setq flyspell-correct-interface #'flyspell-correct-ivy))

Show free keybindings for modkeys or prefixes

(use-package free-keys)

Simple but effective sorting and filtering for Emacs:

(use-package prescient
  :config (prescient-persist-mode))

(use-package ivy-prescient
  :after counsel
  :custom
  (ivy-prescient-sort-commands
    '(:not swiper
           ivy-switch-buffer
           flyspell-correct-ivy))
  :config (ivy-prescient-mode))

(use-package company-prescient
  :config (company-prescient-mode))

Highlight TODO keywords

(use-package hl-todo
  :custom
  (hl-todo-keyword-faces
    '(("TODO"  . "#<<base0B>>")
      ("FIXME" . "#<<base08>>")))
  :config (global-hl-todo-mode))

Powerthesaurus integration for Emacs

(use-package powerthesaurus)

Display ugly ^L page breaks as tidy horizontal lines

(use-package form-feed
  :custom-face
    (form-feed-line ((t (:strike-through "#<<base03>>"))))
  :hook
  ((emacs-lisp-mode lisp-mode scheme-mode compilation-mode
     outline-mode help-mode
   ) . form-feed-mode)
)

Use ace window for window switching.

(use-package ace-window
  :general
  ("M-o" 'ace-window)
)

Theme

Set base 16 theme:

(use-package base16-theme
  :init
  (setq base16-default-dark-colors
  '(:base00 "#<<base00>>"
    :base01 "#<<base01>>"
    :base02 "#<<base02>>"
    :base03 "#<<base03>>"
    :base04 "#<<base04>>"
    :base05 "#<<base05>>"
    :base06 "#<<base06>>"
    :base07 "#<<base07>>"
    :base08 "#<<base08>>"
    :base09 "#<<base09>>"
    :base0A "#<<base0A>>"
    :base0B "#<<base0B>>"
    :base0C "#<<base0C>>"
    :base0D "#<<base0D>>"
    :base0E "#<<base0E>>"
    :base0F "#<<base0F>>"))
  :config
  (load-theme 'base16-default-dark t)
  (custom-set-faces
    '(diff-hl-change ((t (:background "#<<base0E>>" :foreground "#<<base0E>>"))))
    '(diff-hl-delete ((t (:background "#<<base08>>" :foreground "#<<base08>>"))))
    '(diff-hl-insert ((t (:background "#<<base0B>>" :foreground "#<<base0B>>"))))
  )
)

Set the cursor color based on the evil state

(defvar my/base16-colors base16-default-dark-colors)
(setq evil-emacs-state-cursor   `(,(plist-get my/base16-colors :base0D) box)
      evil-insert-state-cursor  `(,(plist-get my/base16-colors :base0D) bar)
      evil-motion-state-cursor  `(,(plist-get my/base16-colors :base0E) box)
      evil-normal-state-cursor  `(,(plist-get my/base16-colors :base0B) box)
      evil-replace-state-cursor `(,(plist-get my/base16-colors :base08) bar)
      evil-visual-state-cursor  `(,(plist-get my/base16-colors :base09) box))

Set color of org-mode verbatim

(set-face-attribute 'org-verbatim nil :foreground "#<<base0F>>")

Set color of org-mode headings

(custom-set-faces
  '(org-level-1 ((t (:foreground "#<<base08>>" :bold t :underline t))))
  '(org-level-2 ((t (:foreground "#<<base0A>>" :bold t))))
  '(org-level-3 ((t (:foreground "#<<base0D>>" :bold t))))
  '(org-level-4 ((t (:foreground "#<<base0C>>"))))
  '(org-level-5 ((t (:foreground "#<<base0B>>"))))
)

Improve look of org-mode agenda:

(custom-set-faces
  '(org-agenda-date-today ((t (:foreground "#<<base0A>>" :bold t :underline t))))
  '(org-agenda-date ((t (:underline t))))
)