emacs/init.el

311 lines
8.0 KiB
EmacsLisp
Raw Normal View History

2023-08-06 03:10:05 -04:00
;; -*- lexical-binding: t -*-
(progn
(setq inhibit-startup-buffer-menu t)
(setq inhibit-startup-screen t)
(setq initial-buffer-choice t)
(setq initial-scratch-message "")
2023-08-13 16:59:06 -04:00
(setq confirm-kill-emacs 'yes-or-no-p)
2023-08-06 03:10:05 -04:00
(scroll-bar-mode 0)
(tool-bar-mode 0)
(menu-bar-mode 0)
(setq ns-use-proxy-icon nil)
(setq frame-title-format nil)
(add-to-list 'default-frame-alist '(ns-transparent-titlebar . t))
(setq isearch-allow-scroll t)
(setq-default indent-tabs-mode nil)
(setq-default tab-width 4)
(setq show-trailing-whitespace t)
(setq backup-by-copying t)
(set-default-coding-systems 'utf-8)
(set-keyboard-coding-system 'utf-8)
(set-terminal-coding-system 'utf-8)
(defalias 'go-mode 'go-ts-mode)
(defalias 'gomod-mode 'go-mod-ts-mode)
(defvar modus-themes-italic-constructs t)
(defvar modus-themes-bold-constructs nil)
(defvar modus-themes-mode-line '(borderless accented))
(defvar modus-themes-region '(bg-only no-extend))
(load-theme 'modus-vivendi t)
(global-display-line-numbers-mode))
(eval-and-compile
(add-to-list 'load-path (expand-file-name "lib/borg/" user-emacs-directory))
(require 'borg)
(borg-initialize))
(use-package auto-compile
:config
(setq auto-compile-display-buffer nil)
(setq auto-compile-mode-line-counter t)
(setq auto-compile-source-recreate-deletes-dest t)
(setq auto-compile-toggle-deletes-nonlib-dest t))
(use-package epkg
:defer t
:init
(setq epkg-repository (expand-file-name "var/epkgs/" user-emacs-directory)))
(use-package dash
:config (global-dash-fontify-mode))
(use-package server
:commands (server-running-p)
:config (or (server-running-p) (server-mode)))
(use-package magit
:defer t
:commands (magit-add-section-hook)
:config
(magit-add-section-hook 'magit-status-sections-hook
'magit-insert-modules
'magit-insert-stashes
'append))
(use-package evil
:hook (after-init . evil-mode)
:init
(setq evil-want-integration t)
(setq evil-want-keybinding nil)
(evil-mode t)
:config
(evil-set-initial-state 'shell-mode 'normal)
(evil-set-initial-state 'doc-view-mode 'normal)
(evil-set-initial-state 'package-menu-mode 'normal)
(evil-set-initial-state 'biblio-selection-mode 'motion)
(evil-global-set-key 'motion "gs" 'tab-bar-switch-to-tab)
(setq doc-view-continuous t))
(use-package evil-collection
:after evil
:init
(evil-collection-init))
(use-package org
:config
(setq org-confirm-babel-evaluate nil)
(setq org-export-use-babel nil)
(add-hook 'org-babel-after-execute-hook 'org-redisplay-inline-images)
(org-babel-do-load-languages
'org-babel-load-languages
'((emacs-lisp . t)
(plantuml . t)
(C . t)
(java . t)
(shell . t)
(sql . t)
(go . t)
(python . t))))
(use-package vertico
:init
(vertico-mode))
(use-package orderless
:init
(setq completion-styles '(orderless basic)
completion-category-defaults nil
completion-category-overrides '((eglot (styles orderless)) (file (styles partial-completion)))))
(use-package consult
:config
(defun find-fd (&optional dir initial)
(interactive "P")
(let ((consult-find-args "fzf -e"))
(consult-find dir initial)))
(autoload 'projectile-project-root "projectile")
(setq consult-project-root-function #'projectile-project-root))
(use-package embark)
(use-package embark-consult
:hook
(embark-collect-mode . consult-preview-at-point-mode))
(use-package marginalia
:custom
(marginalia-align 'right)
:init
(marginalia-mode))
(use-package which-key
:init (which-key-mode t))
(use-package general
:after which-key
:config
(general-override-mode t)
(general-auto-unbind-keys)
(general-define-key
:keymaps 'key-translation-map
"ESC" (kbd "C-g"))
(general-def
"C-x x" 'eval-defun)
(general-create-definer tyrant-def
:states '(normal visual insert motion emacs)
:prefix "SPC"
:non-normal-prefix "C-SPC")
(tyrant-def
"" nil
"SPC" (general-simulate-key "M-x")
"c" (general-simulate-key "C-c")
"h" (general-simulate-key "C-h")
"u" (general-simulate-key "C-u")
"x" (general-simulate-key "C-x")
"w" (general-simulate-key "C-w")
":" 'shell-command
"git" 'magit
"rg" 'consult-ripgrep
"fzf" 'consult-find
"em" '(:ignore t :which-key "emacs")
"emr" (lambda ()
(interactive)
(load-file user-init-file))
"emd" (lambda ()
(interactive)
(find-file user-init-file))
2023-08-13 16:57:44 -04:00
"th" '(:ignore t :which-key "themes")
"ths" 'consult-theme
"ta" '(:ignore t :which-key "tabs")
"tac" 'tab-new
"taq" 'tab-close
"tar" 'tab-rename
2023-08-06 03:10:05 -04:00
"b" '(:ignore t :which-key "buffers")
"bl" 'switch-to-buffer
"bd" 'kill-this-buffer
"f" '(:ignore t :which-key "files")
"ff" 'find-file
"fr" 'rename-file-and-buffer
"p" '(:ignore t :which-key "projects")
"pf" 'projectile-find-file
2023-08-13 16:57:44 -04:00
"pp" 'projectile-switch-project
"pb" 'projectile-switch-to-buffer
2023-08-06 03:10:05 -04:00
"o" '(:ignore t :which-key "org")
"oi" 'org-insert-structure-template
"odu" 'org-update-all-dblocks
2023-08-13 16:57:44 -04:00
"n" '(:ignore t :which-key "notes")
2023-08-06 03:10:05 -04:00
"nl" 'consult-notes
2023-08-13 16:57:44 -04:00
"x" '(:ignore t :which-key "xref")
"xr" 'xref-find-references
"xd" 'xref-find-definitions
2023-08-06 03:10:05 -04:00
))
(use-package corfu
:init
(global-corfu-mode))
(use-package projectile
:init
(projectile-mode t)
:config
(setq projectile-require-project-root nil)
(setq projectile-find-dir-includes-top-level t)
(setq projectile-project-search-path '(
"~/work/ost/"
"~/work/private"
)))
(use-package denote
:config
(setq denote-directory (expand-file-name "~/denote"))
(defun x/denote-journal ()
(interactive)
(let* ((today (format-time-string "%A %e %B %Y"))
(string (denote-sluggify today))
(files (denote-directory-files-matching-regexp string)))
(cond
((> (length files) 1)
(find-file (completing-read "Select file: " files nil :require-match)))
(files
(find-file (car files)))
(t
(denote
today
'("journal"))))))
(defun x/denote-append-region-to-note (beg end)
(interactive "r")
(if-let (((region-active-p))
(text (buffer-substring-no-properties beg end)))
(progn
(consult-notes)
(goto-char (point-max))
(insert text))
(user-error "No region is available")))
)
(use-package consult-notes
:config
(consult-notes-denote-mode))
(use-package rainbow-delimiters
:config
(set-face-foreground 'rainbow-delimiters-depth-1-face "#c66")
(set-face-foreground 'rainbow-delimiters-depth-2-face "#6c6")
(set-face-foreground 'rainbow-delimiters-depth-3-face "#69f")
(set-face-foreground 'rainbow-delimiters-depth-4-face "#cc6")
(set-face-foreground 'rainbow-delimiters-depth-5-face "#6cc")
(set-face-foreground 'rainbow-delimiters-depth-6-face "#c6c")
(set-face-foreground 'rainbow-delimiters-depth-7-face "#ccc")
(set-face-foreground 'rainbow-delimiters-depth-8-face "#999")
(set-face-foreground 'rainbow-delimiters-depth-9-face "#666"))
(use-package lisp-mode
:config
(add-hook 'lisp-mode-hook 'rainbow-delimiters-mode)
(add-hook 'emacs-lisp-mode-hook 'rainbow-delimiters-mode))
(use-package no-littering)
(use-package custom
:no-require t
:config
(setq custom-file (expand-file-name "custom.el" user-emacs-directory))
(when (file-exists-p custom-file)
(load custom-file)))
;; http://steve.yegge.googlepages.com/my-dot-emacs-file
(defun rename-file-and-buffer (new-name)
"Renames both current buffer and file it's visiting to NEW-NAME."
(interactive "New name: ")
(let ((name (buffer-name))
(filename (buffer-file-name)))
(if (not filename)
(message "Buffer '%s' is not visiting a file!" name)
(if (get-buffer new-name)
(message "A buffer named '%s' already exists!" new-name)
(progn
(rename-file name new-name t)
(rename-buffer new-name)
(set-visited-file-name new-name)
(set-buffer-modified-p nil))))))