dotfiles/emacs/emacs.legacy/init.el
2021-12-31 17:51:23 -05:00

456 lines
13 KiB
EmacsLisp

;;; init.el --- Summary
;;; Commentary:
;;; Code:
(setq gc-cons-threshold (* 100 1024 1024))
(setq read-process-output-max (* 1024 1024))
(add-to-list 'load-path "~/.emacs.d/custom")
(defvar bootstrap-version)
(let ((bootstrap-file
(expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
(bootstrap-version 5))
(unless (file-exists-p bootstrap-file)
(with-current-buffer
(url-retrieve-synchronously
"https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
'silent 'inhibit-cookies)
(goto-char (point-max))
(eval-print-last-sexp)))
(load bootstrap-file nil 'nomessage))
(straight-use-package 'use-package)
(straight-use-package 'no-littering)
(require 'no-littering)
(require 'recentf)
(add-to-list 'recentf-exclude no-littering-var-directory)
(add-to-list 'recentf-exclude no-littering-etc-directory)
(setq auto-save-file-name-transforms
`((".*" ,(no-littering-expand-var-file-name "auto-save/") t)))
;; Use UTF-8 pls
(prefer-coding-system 'utf-8)
(set-language-environment "UTF-8")
(setq locale-coding-system 'utf-8)
(set-selection-coding-system 'utf-8)
(setq-default buffer-file-coding-system 'utf-8-unix)
(setq org-roam-v2-ack t)
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(async-bytecomp-package-mode t)
'(delete-selection-mode nil)
'(display-line-numbers 'visual)
'(display-line-numbers-current-absolute t)
'(display-line-numbers-grow-only t)
'(display-line-numbers-type 'visual)
'(display-line-numbers-width-start t)
'(epa-file-select-keys 'silent)
'(epg-pinentry-mode 'loopback)
'(evil-cross-lines t)
'(global-whitespace-mode t)
'(indent-tabs-mode nil)
'(inhibit-startup-screen t)
'(org-edit-src-content-indentation 0)
'(org-roam-encrypt-files t)
'(org-src-preserve-indentation t)
'(prescient-filter-method '(literal regexp initialism fuzzy))
'(ring-bell-function 'ignore)
'(rustic-format-trigger 'on-compile)
'(rustic-indent-method-chain t)
'(rustic-indent-where-clause t)
'(straight-use-package-by-default t)
'(straight-vc-git-default-protocol 'ssh)
'(treemacs-collapse-dirs 3)
'(treemacs-filewatch-mode t)
'(treemacs-follow-mode t)
'(treemacs-fringe-indicator-mode nil)
'(treemacs-is-never-other-window t)
'(treemacs-move-forward-on-expand t)
'(treemacs-no-png-images t)
'(treemacs-show-hidden-file t)
'(treemacs-tag-follow-mode t)
'(undo-tree-auto-save-history t)
'(undo-tree-history-directory-alist '(("." . "~/.undohist-emacs")))
'(undo-tree-visualizer-diff t)
'(undo-tree-visualizer-timestamps t)
'(whitespace-style
'(face tabs spaces newline space-mark tab-mark newline-mark)))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(default ((t (:inherit nil :extend nil :stipple nil :background "#322931" :foreground "#b9b5b8" :inverse-video nil :box nil :strike-through nil :overline nil :underline nil :slant normal :weight normal :height 160 :width normal :foundry "nil" :family "Iosevka Custom"))))
'(evil-goggles-change-face ((t (:inherit diff-removed))))
'(evil-goggles-delete-face ((t (:inherit diff-removed))))
'(evil-goggles-paste-face ((t (:inherit diff-added))))
'(evil-goggles-undo-redo-add-face ((t (:inherit diff-added))))
'(evil-goggles-undo-redo-change-face ((t (:inherit diff-changed))))
'(evil-goggles-undo-redo-remove-face ((t (:inherit diff-removed))))
'(evil-goggles-yank-face ((t (:inherit diff-changed))))
'(italic ((t (:slant italic :family "Dank Mono"))))
'(magit-diff-hunk-heading-highlight ((t (:extend t :background "light green"))))
'(whitespace-tab ((t (:inherit default :foreground "#65737d")))))
;; auto-package-update
(use-package auto-package-update
:ensure t
:config
(setq auto-package-update-delete-old-versions t)
(auto-package-update-maybe))
;; Autocomplete
(use-package auto-complete
:config (global-auto-complete-mode t))
;; Theme
(use-package base16-theme
:config (load-theme 'base16-hopscotch t))
(global-prettify-symbols-mode 1)
;; Undo-tree
(use-package undo-tree
:config
(global-undo-tree-mode))
;; EVIL
(use-package evil
:ensure t
:init
(setq evil-want-keybinding nil)
:config
(evil-mode 1))
(use-package evil-collection
:after evil
:ensure t
:config
(evil-collection-init))
(use-package evil-commentary
:ensure t)
(use-package evil-lispy
:ensure t
:after (evil lispy)
:config
(add-hook 'emacs-lisp-mode-hook #'evil-lispy-mode)
(add-hook 'clojure-mode-hook #'evil-lispy-mode))
(use-package evil-expat
:ensure t)
(use-package evil-goggles
:ensure t
:config
(evil-goggles-mode)
;; optionally use diff-mode's faces; as a result, deleted text
;; will be highlighed with `diff-removed` face which is typically
;; some red color (as defined by the color theme)
;; other faces such as `diff-added` will be used for other actions
(evil-goggles-use-diff-faces))
(use-package evil-surround
:after evil
:ensure t
:config
(global-evil-surround-mode 1))
(use-package evil-org
:after (evil 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-set-leader 'normal (kbd "SPC"))
(evil-define-key 'normal 'global (kbd "C-k") 'evil-scroll-up)
(evil-define-key 'normal 'global (kbd "C-j") 'evil-scroll-down)
(evil-define-key 'normal 'global (kbd "<leader>l") 'evil-window-right)
(evil-define-key 'normal 'global (kbd "<leader>h") 'evil-window-left)
(evil-define-key 'normal 'global (kbd "<leader>j") 'evil-window-down)
(evil-define-key 'normal 'global (kbd "<leader>k") 'evil-window-up)
(evil-define-key 'normal 'global (kbd "<leader>x") 'execute-extended-command)
(evil-define-key 'normal 'global (kbd "gc") 'evil-commentary)
(evil-define-key 'normal 'global (kbd "<leader>u") 'undo-tree-visualize)
(evil-define-key 'normal 'global (kbd "<leader> b") 'consult-buffer)
;; Avy
(use-package avy
:config
(evil-define-key 'normal 'global (kbd "<leader>a") 'avy-goto-char-timer))
(use-package dash)
;; Magit
(use-package magit
:config
(evil-define-key 'normal 'global (kbd "<leader>g") 'magit-file-dispatch)
(evil-define-key 'normal 'global (kbd "<leader>r") 'magit-status))
(use-package magit-delta
:after (magit)
:if (executable-find "delta")
:config
(add-hook 'magit-mode-hook (lambda () (magit-delta-mode +1))))
;; Lispy
(use-package lispy
:config (add-hook 'emacs-lisp-mode-hook (lambda () (lispy-mode 1))))
;; smartparens
(use-package smartparens
:config (smartparens-global-mode t))
;; which-key
(use-package which-key
:after (evil)
:init
(setq which-key-show-operator-state-maps t)
:config (which-key-mode))
;; Git gutter
(use-package git-gutter
:config (global-git-gutter-mode 1))
;; Rainbow Delims
(use-package rainbow-delimiters
:config (add-hook 'prog-mode-hook 'rainbow-delimiters-mode))
;; Super Save
(use-package super-save
:config
(super-save-mode 1))
;; EditorConfig
(use-package editorconfig
:ensure t
:config
(editorconfig-mode 1))
;; Wakatime
;; (use-package wakatime-mode
;; :hook (after-init . global-wakatime-mode))
;; Just-mode
(use-package just-mode)
;; justl - command runner for justfiles
(use-package justl)
;; Groovy-mode
(use-package groovy-mode)
;; Terraform-mode
(use-package terraform-mode)
;; YAML mode
(use-package yaml-mode)
;; Lua mode
(use-package lua-mode)
;; Go mode
(use-package go-mode)
;; Systemd mode
(use-package systemd)
;; Apache config mode
(use-package apache-mode)
;; Dockerfile Mode
(use-package dockerfile-mode
:config
(add-to-list 'auto-mode-alist '("Dockerfile\\'" . dockerfile-mode)))
;; Origamimode
(use-package origami
:ensure evil
:config (global-origami-mode t)
(evil-define-key 'normal 'global (kbd "<leader> f o") 'origami-open-node)
(evil-define-key 'normal 'global (kbd "<leader> f c") 'origami-close-node)
(evil-define-key 'normal 'global (kbd "<leader> f O") 'origami-open-all-nodes)
(evil-define-key 'normal 'global (kbd "<leader> f C") 'origami-close-all-nodes)
(evil-define-key 'normal 'global (kbd "<leader> f t") 'origami-show-only-node))
;; Page-break-lines
(use-package page-break-lines
:ensure t
:config (global-page-break-lines-mode 1))
;; Dashboard
(use-package dashboard
:ensure t
:config
(dashboard-setup-startup-hook)
(setq dashboard-banner-logo-title "Welcome to Emacs Dashboard")
(setq dashboard-center-content t))
;; Tree Sitter
(use-package tree-sitter
:straight (tree-sitter :type git :host nil :repo "git@github.com:anthonycicc/elisp-tree-sitter" :branch "release")
:config
(global-tree-sitter-mode)
(add-hook 'tree-sitter-after-on-hook #'tree-sitter-hl-mode))
;; Tree-sitter-langs
(use-package tree-sitter-langs
:straight (tree-sitter-langs :type git :host github :repo "emacs-tree-sitter/tree-sitter-langs")
:after (tree-sitter))
;; Org Mode
(use-package org
:mode (("\\.org$" . org-mode))
:ensure org
:pin gnu
:config
(evil-define-key 'normal 'global (kbd "<leader> SPC s") 'org-store-link)
(evil-define-key 'normal 'global (kbd "<leader> SPC a") 'org-agenda)
(evil-define-key 'normal 'global (kbd "<leader> SPC c") 'org-capture)
(evil-define-key 'normal 'global (kbd "<leader> SPC l") 'org-insert-link)
(evil-define-key 'normal 'global (kbd "g [") 'org-open-at-point))
(use-package org-roam
:straight (org-roam
:host github
:repo "org-roam/org-roam")
:after (org)
:config
(setq org-roam-directory "~/org-roam")
(setq org-roam-encrypt-files t)
(setq org-roam-index-file "Index")
(org-roam-setup))
(setq epa-file-encrypt-to '("anthony@anthonycicchetti.com"))
;; (use-package epa-file
;; :ensure nil
;; :config
;; (setq epa-file-encrypt-to '("anthony@anthonycicchetti.com"))
;; :custom
;; (epa-file-select-keys 'silent))
(require 'org-crypt)
(org-crypt-use-before-save-magic)
(setq org-tags-exclude-from-inheritance '("crypt"))
(setq org-crypt-key "anthony@anthonycicchetti.com")
;; (use-package org-crypt
;; :ensure nil ;; included with org-mode
;; :after org
;; :config
;; (org-crypt-use-before-save-magic)
;; (setq org-tags-exclude-from-inheritance '("crypt"))
;; :custom
;; (org-crypt-key "anthony@anthonycicchetti.com"))
(use-package toc-org
:after (org)
:config
(add-hook 'org-mode-hook 'toc-org-mode)
(add-hook 'markdown-mode-hook 'toc-org-mode))
(use-package ox-pandoc
:after (org)
:if (executable-find "pandoc"))
(use-package ox-jira
:after (org))
(use-package flycheck
:init (global-flycheck-mode))
(use-package treemacs
:after (evil)
:config
(treemacs-git-mode 'deferred)
(evil-define-key 'normal 'global (kbd "<leader> i") 'treemacs-select-window))
(use-package treemacs-evil
:after (treemacs evil))
(use-package treemacs-magit
:after (treemacs magit))
;; Prescient
(use-package prescient)
(use-package selectrum-prescient
:after (prescient selectrum)
:init
(selectrum-prescient-mode 1))
;; Selectrum
(use-package selectrum
:init
(selectrum-mode 1))
;; Consult, Marginalia, embark
(use-package consult
:after (evil)
:config
(evil-define-key 'normal 'global (kbd "<leader> c f") 'find-fd)
(evil-define-key 'normal 'global (kbd "<leader> c g") 'consult-ripgrep)
:init
(defun find-fd (&optional dir initial)
(interactive "P")
(let ((consult-find-command "fd --color=never --full-path ARG OPTS"))
(consult-find dir initial))) (fset 'multi-occur #'consult-multi-occur)
(advice-add #'register-preview :override #'consult-register-window)
:config)
(use-package consult-flycheck
:after (consult flycheck)
:bind (:map flycheck-command-map
("!" . consult-flycheck)))
(use-package marginalia
:init
(marginalia-mode)
(advice-add #'marginalia-cycle :after
(lambda () (when (bound-and-true-p selectrum-mode) (selectrum-exhibit 'keep-selected))))
(setq marginalia-annotators '(marginalia-annotators-heavy marginalia-annotators-light nil)))
(use-package embark
:ensure t
:after (evil)
:init
(evil-define-key 'normal 'global (kbd "<leader> e") 'embark-act)
(setq embark-action-indicator
(lambda (map _target)
(which-key--show-keymap "Embark" map nil nil #'no-paging)
#'which-key--hide-popup-ignore-command)
embark-become-indicator embark-action-indicator))
;; Consult users will also want the embark-consult package.
(use-package embark-consult
:ensure t
:after (embark consult)
:demand t
:hook
(embark-collect-mode . embark-consult-preview-minor-mode))
(if (file-directory-p "~/.emacs.d/custom")
(require 'lsp))
(if (file-directory-p "~/.emacs.d/custom")
(require 'elfeed))
(progn
(setq whitespace-style '(face spaces tabs newline space-mark tab-mark newline-mark))
(setq whitespace-display-mappings
'(
(space-mark 32 [8227] [183] [46])
(newline-mark 10 [172 10] [182 10])
(tab-mark 9 [8594 32 32 32] [8614]))))