dotfiles/emacs/init.el

411 lines
12 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")
(require 'package)
(add-to-list 'package-archives
'(
"melpa" . "https://melpa.org/packages/") t)
(add-to-list 'package-archives
'("org" . "https://orgmode.org/elpa/")
t)
(package-initialize)
(unless package-archive-contents
(package-refresh-contents))
(unless (package-installed-p 'use-package)
(package-refresh-contents)
(package-install 'use-package))
(eval-when-compile
(require 'use-package))
(use-package no-littering
:ensure t
:config
(require 'recentf)
(eval-when-compile (defvar recentf-exclude))
(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)))
)
(require 'use-package-ensure)
(setq use-package-always-ensure 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)
(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)
'(evil-cross-lines t)
'(global-whitespace-mode t)
'(indent-tabs-mode nil)
'(inhibit-startup-screen t)
'(package-archives
'(("gnu" . "https://elpa.gnu.org/packages/")
("melpa" . "https://melpa.org/packages/")
("org" . "https://orgmode.org/elpa/")))
'(package-selected-packages
'(ox-jira consult embark-consult embark selectrum-prescient prescient marginalia consult-flycheck consult-selectrum selectrum lua-mode lsp-mode yaml-mode evil-lispy treemacs-magit treemacs-evil treemacs lsp-pyright lsp-ui rustic flycheck origami groovy-mode avy editorconfig org-crypt tree-sitter-langs tree-sitter centaur-tabs dashboard page-break-lines wakatime-mode super-save ox-pandoc evil-surround evil-collection undo-tree toc-org evil-org org-plus-contrib evil-goggles evil-expat evil-commentary auto-package-update lispy smartparens which-key git-gutter rainbow-delimiters auto-complete-distel auto-complete evil magit evil-magit))
'(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)
'(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"))))
'(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>i") 'help)
(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))
;; 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))
;; 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))
;; Groovy-mode
(use-package groovy-mode)
;; YAML mode
(use-package yaml-mode)
;; Lua mode
(use-package lua-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))
(if (not (string-match "^aarch64-.*" system-configuration))
(progn
;; Tree-sitter
(use-package tree-sitter
:config
(global-tree-sitter-mode)
(add-hook 'tree-sitter-after-on-hook #'tree-sitter-hl-mode))
;; Tree-sitter-langs
(use-package tree-sitter-langs
:after (tree-sitter)))
())
;; Org Mode
(use-package org
:mode (("\\.org$" . org-mode))
:ensure org-plus-contrib
: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 epa-file
:ensure nil
:config
(setq epa-file-encrypt-to '("anthony@anthonycicchetti.com"))
:custom
(epa-file-select-keys 'silent))
(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))
(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))
(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]))))