2024-08-20 17:33:23 -04:00
;;; init.el --- GNU Emacs Initialization File -*- lexical-binding: t; -*-
2023-08-10 00:59:36 -04:00
2024-08-20 17:33:23 -04:00
;; Author: Andrew Scott <git at andyscott dot me>
2023-08-10 00:59:36 -04:00
;; Keywords: convenience, tools
;; URL: https://codeberg.org/andyscott/dotfiles
;; This file is not part of GNU Emacs.
2024-08-20 17:33:23 -04:00
;; Copyright (c) 2023 Andrew Scott
2023-08-10 00:59:36 -04:00
;; MIT No Attribution
;; Permission is hereby granted, free of charge, to any person obtaining a copy of this
;; software and associated documentation files (the "Software"), to deal in the Software
;; without restriction, including without limitation the rights to use, copy, modify,
;; merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
;; permit persons to whom the Software is furnished to do so.
;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
;; INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
;; PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
;; HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
;; OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
;; SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2024-08-20 17:33:23 -04:00
;;; Commentary:
;; My Emacs initialization file.
2023-08-10 00:59:36 -04:00
;;; Code:
2024-08-20 17:33:23 -04:00
;; Profile init time
;; Replace `emacs-startup-hook' w/ `elpaca-after-init-hook' to profile `Elpaca'
2023-08-30 03:38:04 -04:00
( add-hook 'emacs-startup-hook
2023-08-10 00:59:36 -04:00
( lambda ( )
( message " Emacs loaded in %s with %d garbage collections. "
( format " %.2f seconds "
( float-time
( time-subtract ( current-time ) before-init-time ) ) )
gcs-done ) ) )
2023-11-26 23:54:45 -05:00
2024-08-20 17:33:23 -04:00
;; View profiler report after init
;; (profiler-start 'cpu+mem)
;; (add-hook 'elpaca-after-init-hook (lambda () (profiler-stop) (profiler-report)))
;; Profile function performance
;; (require 'elp)
;; (with-eval-after-load file
;; (elp-instrument-package file))
;; (add-hook 'elpaca-after-init-hook
;; (lambda () (elp-results) (elp-restore-package (intern file))))
;; Elpaca
2024-03-20 10:34:10 -04:00
( defvar elpaca-installer-version 0.7 )
2023-08-10 00:59:36 -04:00
( defvar elpaca-directory ( expand-file-name " elpaca/ " user-emacs-directory ) )
( defvar elpaca-builds-directory ( expand-file-name " builds/ " elpaca-directory ) )
( defvar elpaca-repos-directory ( expand-file-name " repos/ " elpaca-directory ) )
( defvar elpaca-order ' ( elpaca :repo " https://github.com/progfolio/elpaca.git "
2024-08-20 17:33:23 -04:00
:ref nil :depth 1
:files ( :defaults " elpaca-test.el " ( :exclude " extensions " ) )
2023-08-10 00:59:36 -04:00
:build ( :not elpaca--activate-package ) ) )
( let* ( ( repo ( expand-file-name " elpaca/ " elpaca-repos-directory ) )
( build ( expand-file-name " elpaca/ " elpaca-builds-directory ) )
( order ( cdr elpaca-order ) )
( default-directory repo ) )
( add-to-list 'load-path ( if ( file-exists-p build ) build repo ) )
( unless ( file-exists-p repo )
( make-directory repo t )
( when ( < emacs-major-version 28 ) ( require 'subr-x ) )
( condition-case-unless-debug err
( if-let ( ( buffer ( pop-to-buffer-same-window " *elpaca-bootstrap* " ) )
2024-08-20 17:33:23 -04:00
( ( zerop ( apply #' call-process ` ( " git " nil , buffer t " clone "
,@ ( when-let ( ( depth ( plist-get order :depth ) ) )
( list ( format " --depth=%d " depth ) " --no-single-branch " ) )
, ( plist-get order :repo ) , repo ) ) ) )
2023-08-10 00:59:36 -04:00
( ( zerop ( call-process " git " nil buffer t " checkout "
( or ( plist-get order :ref ) " -- " ) ) ) )
( emacs ( concat invocation-directory invocation-name ) )
( ( zerop ( call-process emacs nil buffer nil " -Q " " -L " " . " " --batch "
" --eval " " (byte-recompile-directory \" . \" 0 'force) " ) ) )
( ( require 'elpaca ) )
( ( elpaca-generate-autoloads " elpaca " repo ) ) )
( progn ( message " %s " ( buffer-string ) ) ( kill-buffer buffer ) )
( error " %s " ( with-current-buffer buffer ( buffer-string ) ) ) )
( ( error ) ( warn " %s " err ) ( delete-directory repo 'recursive ) ) ) )
( unless ( require 'elpaca-autoloads nil t )
( require 'elpaca )
( elpaca-generate-autoloads " elpaca " repo )
( load " ./elpaca-autoloads " ) ) )
( add-hook 'after-init-hook #' elpaca-process-queues )
( elpaca ` ( ,@ elpaca-order ) )
2024-10-06 00:51:46 -04:00
;; Ensure `Elpaca' doesn't pull built-in packages from source
2024-08-20 17:33:23 -04:00
( defmacro use-feature ( name &rest args )
" Like `use-package' but accounting for asynchronous installation.
NAME and ARGS are in ` use-package '. Credit to @progfolio:
https://github.com/progfolio/.emacs.d?tab=readme-ov-file#use-package "
( declare ( indent defun ) )
` ( use-package , name
:ensure nil
,@ args ) )
2024-01-13 01:07:16 -05:00
2023-08-10 00:59:36 -04:00
( elpaca elpaca-use-package
2024-08-20 17:33:23 -04:00
( require 'elpaca-use-package )
2023-08-10 00:59:36 -04:00
( elpaca-use-package-mode )
2024-10-06 00:51:46 -04:00
( setopt use-package-always-ensure t
;; REVIEW - apparently `use-package-always-pin' doesn't work with `Elpaca'
;; TODO - remove stats when done profiling startup
use-package-compute-statistics t ) )
2023-08-10 00:59:36 -04:00
2024-08-20 17:33:23 -04:00
( if debug-on-error
( setopt use-package-verbose t
use-package-expand-minimally nil
use-package-compute-statistics t )
( setopt use-package-verbose nil
use-package-expand-minimally t ) )
2023-08-10 00:59:36 -04:00
2024-08-20 17:33:23 -04:00
;; Wait for `Elpaca' to process current queue
( elpaca-wait )
2023-09-04 03:42:08 -04:00
2024-08-20 17:33:23 -04:00
;;; Built-in Packages:
2023-09-04 03:42:08 -04:00
2024-08-20 17:33:23 -04:00
;; Revert a buffer if the file has changed
( use-feature autorevert
2024-10-06 00:51:46 -04:00
:config
( setopt auto-revert-interval 10 )
( global-auto-revert-mode )
:defer 5
2024-08-20 17:33:23 -04:00
:init ( setopt auto-revert-interval 0.01 ) )
2024-10-06 00:51:46 -04:00
( use-feature bibtex
:after ( ebib )
:config ( setopt bibtex-autokey-additional-names " EtAl "
bibtex-autokey-edit-before-use t ; "t" by default
bibtex-autokey-expand-strings t
bibtex-autokey-name-case-convert-function #' capitalize
bibtex-autokey-name-year-separator " "
bibtex-autokey-names-stretch 1
bibtex-autokey-titlewords 2
bibtex-autokey-titlewords-stretch 1
bibtex-autokey-titleword-length #' infty
bibtex-autokey-titleword-separator " "
bibtex-autokey-titleword-case-convert-function #' capitalize
bibtex-autokey-year-length 4
bibtex-autokey-year-length 4
bibtex-autokey-year-title-separator " " ) )
( use-feature c-ts-mode
:commands ( c-ts-mode )
:config
( setopt c-ts-mode-indent-style 'linux
c-ts-mode-indent-offset 8
indent-tabs-mode t ) )
( use-feature c++-ts-mode
:commands ( c++-ts-mode )
:config
( setopt c++-ts-mode-indent-style 'gnu
c-ts-mode-indent-offset 4 ) )
2024-08-20 17:33:23 -04:00
;; Customize compilation & related buffers
( use-feature compile
2023-08-28 13:02:51 -04:00
:commands ( compile recompile )
2024-08-20 17:33:23 -04:00
:config ( setopt compilation-ask-about-save nil
2024-10-06 00:51:46 -04:00
compilation-scroll-output 'first-error )
:hook ( compilation-filter . ansi-color-compilation-buffer ) )
2023-08-28 13:02:51 -04:00
2024-08-20 17:33:23 -04:00
;; Write external customizations to /dev/null
( use-feature cus-edit
:init ( setopt custom-file null-device ) )
2023-08-28 13:02:51 -04:00
2024-10-06 00:51:46 -04:00
;; Library for creating/customizing user options
2024-09-02 12:15:55 -04:00
( use-feature custom
:config ( setopt custom-safe-themes t ) )
2024-10-06 00:51:46 -04:00
;; File manager
( use-feature dired
:commands ( dired )
:config
( setopt dired-kill-when-opening-new-dired-buffer t
dired-mouse-drag-files t ) )
2024-08-20 17:33:23 -04:00
;; Customize fill column indicator
( use-feature display-fill-column-indicator
2023-08-28 13:02:51 -04:00
:hook ( ( conf-mode
markdown-mode
2024-05-18 13:02:27 -04:00
prog-mode ) . display-fill-column-indicator-mode ) )
2023-08-10 00:59:36 -04:00
2024-08-20 17:33:23 -04:00
;; Customize line number display
( use-feature display-line-numbers
:hook ( ( conf-mode
prog-mode ) . display-line-numbers-mode ) )
;; Customize LSP options
( use-feature eglot
:bind
( :map eglot-mode-map
2024-10-06 00:51:46 -04:00
( " C-c e a " . eglot-code-actions )
( " C-c e o " . eglot-code-actions-organize-imports )
( " C-c e r " . eglot-rename )
( " C-c e f " . eglot-format ) )
:config
( add-to-list 'eglot-server-programs ' ( astro-mode . ( " astro-ls " " --stdio "
:initializationOptions
( :typescript ( :tsdk " /usr/lib/node_modules/typescript/lib " ) ) ) ) )
( add-to-list 'eglot-server-programs ' ( ( rust-ts-mode rust-mode ) . ( " rustup " " run " " stable " " rust-analyzer "
:initializationOptions
( :check ( :command " clippy " ) ) ) ) )
2024-08-20 17:33:23 -04:00
( setopt eglot-autoshutdown t
eglot-ignored-server-capabilities
2024-10-06 00:51:46 -04:00
' ( :colorProvider ; "Decorate color references"
2024-08-20 17:33:23 -04:00
;; :documentFormattingProvider ; "Format buffer"
;; :documentHighlightProvider ; "Highlight symbols automatically"
:documentOnTypeFormattingProvider ; "On-type formatting"
;; :documentRangeFormattingProvider ; "Format portion of buffer"
2024-10-06 00:51:46 -04:00
:hoverProvider ; "Documentation on hover"
2024-08-20 17:33:23 -04:00
:inlayHintProvider ; "Inlay hints"
) )
2024-06-11 07:33:21 -04:00
:hook ( ( astro-mode
2024-10-06 00:51:46 -04:00
bash-ts-mode
2024-06-11 07:33:21 -04:00
c-ts-mode
2024-07-09 08:56:24 -04:00
c++-ts-mode
2024-10-06 00:51:46 -04:00
python-ts-mode
2024-08-20 17:33:23 -04:00
rust-ts-mode
2024-10-06 00:51:46 -04:00
sh-script
2024-06-11 07:33:21 -04:00
zig-mode ) . eglot-ensure ) )
2024-05-18 13:02:27 -04:00
2024-08-20 17:33:23 -04:00
;; Automatic parenthesis/brackets matching
( use-feature elec-pair
:hook ( ( conf-mode
markdown-mode
prog-mode ) . electric-pair-mode ) )
;; Options defined in C source code & other misc. global customizations
( use-feature emacs
:bind
( :map global-map
2024-10-06 00:51:46 -04:00
;; Disable `suspend-frame' shortcut (currently overwritten by undo-fu anyway)
2024-08-20 17:33:23 -04:00
( " C-z " . nil )
2024-10-06 00:51:46 -04:00
( " C-x k " . my-kill-buffer )
2024-08-20 17:33:23 -04:00
;; Escape behaves like C-g
( " <escape> " . keyboard-escape-quit )
;; Resizing buffers
( " S-C-<left> " . shrink-window-horizontally )
( " S-C-<right> " . enlarge-window-horizontally )
( " S-C-<down> " . shrink-window )
( " S-C-<up> " . enlarge-window ) )
:config
2024-10-06 00:51:46 -04:00
( setopt completion-ignore-case t
cursor-type 'bar
enable-recursive-minibuffers t
fill-column 79
history-delete-duplicates t
minibuffer-prompt-properties ; Disable prompt in minibuffer
' ( read-only t cursor-intangible t face minibuffer-prompt )
read-buffer-completion-ignore-case t
2024-08-20 17:33:23 -04:00
scroll-step 1
scroll-conservatively 1000
2024-10-06 00:51:46 -04:00
scroll-preserve-screen-position t
sentence-end-double-space nil
tab-always-indent 'complete
use-short-answers t )
:hook ( minibuffer-setup . cursor-intangible-mode )
2024-08-20 17:33:23 -04:00
:init
2024-10-06 00:51:46 -04:00
( defun my-kill-buffer ( )
( interactive )
( catch 'quit
( save-window-excursion
( let ( done )
( when ( and buffer-file-name ( buffer-modified-p ) )
( while ( not done )
( let ( ( response ( read-char-choice
( format " Save file %s? (y, n, d, q) " ( buffer-file-name ) )
' ( ?y ?n ?d ?q ) ) ) )
( setq done ( cond
( ( eq response ?q ) ( throw 'quit nil ) )
( ( eq response ?y ) ( save-buffer ) t )
( ( eq response ?n ) ( set-buffer-modified-p nil ) t )
( ( eq response ?d ) ( diff-buffer-with-file ) nil ) ) ) ) ) )
( kill-buffer ( current-buffer ) )
( force-mode-line-update ) ) ) ) )
;; For Vertico
2024-08-20 17:33:23 -04:00
( defun crm-indicator ( args )
( cons ( format " [CRM%s] %s "
( replace-regexp-in-string
" \\ ` \\ [.*?] \\ * \\ | \\ [.*?] \\ * \\ ' " " "
crm-separator )
( car args ) )
( cdr args ) ) )
2024-10-06 00:51:46 -04:00
( advice-add #' completing-read-multiple :filter-args #' crm-indicator ) )
2023-08-10 00:59:36 -04:00
2024-08-20 17:33:23 -04:00
;; Customize file handling & automatic backups
( use-feature files
2023-08-30 03:38:04 -04:00
:config
2023-09-04 03:42:08 -04:00
( let ( ( auto_save_directory ( concat xdg_cache_home " auto-save-list/ " ) ) )
2023-11-26 23:54:45 -05:00
( unless ( file-directory-p auto_save_directory )
( make-directory auto_save_directory ) )
2024-08-20 17:33:23 -04:00
( setopt backup-directory-alist ` ( ( " .* " . , auto_save_directory ) )
2024-10-06 00:51:46 -04:00
auto-save-list-file-prefix ( concat auto_save_directory " saves- " )
auto-save-file-name-transforms ` ( ( " .* " , auto_save_directory t ) ) ) )
2024-08-20 17:33:23 -04:00
( setopt backup-by-copying t
confirm-kill-processes nil
delete-old-versions t
kept-new-versions 5
kept-old-versions 3
require-final-newline t
2024-10-06 00:51:46 -04:00
version-control t )
;; Treesit doesn't play nice in Emacs 29
;; REVIEW: Putting this here for now because `major-mode-remap-alist' belongs to `files'
( add-to-list 'major-mode-remap-alist ' ( c++-mode . c++-ts-mode ) )
( add-to-list 'major-mode-remap-alist ' ( python-mode . python-ts-mode ) ) )
2024-08-20 17:33:23 -04:00
;; Customize syntax checking
( use-feature flymake
:bind
( :map flymake-mode-map
( " C-c f d " . flymake-show-buffer-diagnostics )
( " C-c f D " . flymake-show-project-diagnostics )
( " C-c f n " . flymake-goto-next-error )
( " C-c f p " . flymake-goto-prev-error ) ) )
;; Customize spell checking
( use-feature flyspell
2023-08-28 13:02:51 -04:00
:hook
2023-11-26 23:54:45 -05:00
( ( ( git-commit-mode
2024-10-06 00:51:46 -04:00
org-mode ) . flyspell-mode ) )
:init ( setopt flyspell-use-meta-tab nil ) )
2023-08-10 00:59:36 -04:00
2024-08-20 17:33:23 -04:00
;; Customize frame behavior/cursor blinking
( use-feature frame
:config ( setopt blink-cursor-delay 1.0
blink-cursor-interval 0.75 ) )
2024-10-06 00:51:46 -04:00
( use-feature help
:config ( setopt help-enable-variable-value-editing t
help-window-select t )
:defer 3 )
( use-feature minibuffer
:config ( setopt read-file-name-completion-ignore-case t ) )
2024-08-20 17:33:23 -04:00
;; Ensure UTF-8 terminal encoding
( use-feature mule
:config ( unless ( display-graphic-p )
( set-terminal-coding-system 'utf-8 ) ) )
;; Customize mouse wheel
( use-feature mwheel
2023-08-30 03:38:04 -04:00
:config
2024-08-20 17:33:23 -04:00
( setopt mouse-wheel-follow-mouse t
mouse-wheel-progressive-speed nil
mouse-wheel-scroll-amount ' ( 2 ( ( shift ) . 1 ) ) ) )
2023-08-30 03:38:04 -04:00
2024-10-06 00:51:46 -04:00
;; Customize comment insertion
( use-feature newcomment
:config ( setopt comment-style 'multi-line ) )
2024-08-20 17:33:23 -04:00
;; Visualize matching parenthesis/brackets
( use-feature paren
:hook ( ( conf-mode
markdown-mode
prog-mode ) . show-paren-mode ) )
2023-08-10 00:59:36 -04:00
2024-08-20 17:33:23 -04:00
;; Enable smooth mouse wheel scrolling when available
( when ( fboundp 'pixel-scroll-precision-mode )
( use-feature pixel-scroll
2024-10-06 00:51:46 -04:00
:config ( pixel-scroll-precision-mode )
:defer 1 ) )
2024-08-20 17:33:23 -04:00
2024-10-06 00:51:46 -04:00
;; Customize project management
2024-08-20 17:33:23 -04:00
( use-feature project
2024-10-06 00:51:46 -04:00
:commands ( project-find-dir project-find-file project-switch-project )
2024-08-20 17:33:23 -04:00
:config ( setopt project-vc-extra-root-markers ' ( " Cargo.toml " ) ) )
;; Customize handling of recent files
( use-feature recentf
2023-08-10 00:59:36 -04:00
:config
2024-10-06 00:51:46 -04:00
( setopt recentf-auto-cleanup 600
recentf-max-menu-items 100
recentf-max-saved-items 100
2024-08-26 16:43:30 -04:00
recentf-save-file ( expand-file-name " recentf " xdg_cache_home ) )
2023-08-30 03:38:04 -04:00
( recentf-mode ) )
2023-08-10 00:59:36 -04:00
2024-08-20 17:33:23 -04:00
;; Customize saving mini-buffer history
( use-feature savehist
2023-08-10 00:59:36 -04:00
:config
2024-10-06 00:51:46 -04:00
( setopt savehist-additional-variables ' ( compile-command kill-buffer kill-ring )
savehist-autosave-interval 120
2024-08-26 16:43:30 -04:00
savehist-file ( expand-file-name " history " xdg_cache_home ) )
2024-10-06 00:51:46 -04:00
( savehist-mode )
:defer 1 )
2023-08-10 00:59:36 -04:00
2024-08-20 17:33:23 -04:00
;; Customize saving place in files
( use-feature saveplace
2023-08-30 03:38:04 -04:00
:config
2024-08-26 16:43:30 -04:00
( setopt save-place-file ( expand-file-name " places " xdg_cache_home ) )
2023-08-30 03:38:04 -04:00
( save-place-mode ) )
2024-08-20 17:33:23 -04:00
;; Unload `seq' before `Elpaca' starts building
;; https://github.com/progfolio/elpaca/issues/216#issuecomment-1868444883
( defun +elpaca-unload-seq ( e )
( and ( featurep 'seq ) ( unload-feature 'seq t ) )
( elpaca--continue-build e ) )
( defun +elpaca-seq-build-steps ( )
( append ( butlast ( if ( file-exists-p ( expand-file-name " seq " elpaca-builds-directory ) )
elpaca--pre-built-steps elpaca-build-steps ) )
( list '+elpaca-unload-seq 'elpaca--activate-package ) ) )
2024-01-13 01:07:16 -05:00
( use-package seq
2024-02-20 11:43:17 -05:00
:ensure ` ( seq :build , ( +elpaca-seq-build-steps ) ) )
2024-01-13 01:07:16 -05:00
2024-10-06 00:51:46 -04:00
( use-feature shell
:hook ( shell-mode . ansi-color-for-comint-mode-on ) )
2024-08-20 17:33:23 -04:00
;; "A grab-bag of basic Emacs commands"
( use-feature simple
2023-08-30 03:38:04 -04:00
:config
2024-08-20 17:33:23 -04:00
( setopt indent-tabs-mode nil
read-extended-command-predicate #' command-completion-default-include-p )
2023-08-28 13:02:51 -04:00
:hook
2024-08-20 17:33:23 -04:00
( ( ( conf-mode
prog-mode ) . column-number-mode )
( text-mode . auto-fill-mode ) ) )
2023-08-10 00:59:36 -04:00
2024-08-20 17:33:23 -04:00
;; Customize tree-sitter parsing
( use-feature treesit
2024-10-06 00:51:46 -04:00
:config ( setopt treesit-font-lock-level 4 )
:defer 1 )
;; Remember to take breaks
( use-feature type-break
:config ( setopt type-break-keystroke-threshold ' ( nil . nil ) )
:commands ( type-break-mode ) )
2023-08-28 13:02:51 -04:00
2024-08-20 17:33:23 -04:00
;; Customize whitespace visualization & cleanup
( use-feature whitespace
:config
( add-hook 'before-save-hook #' whitespace-cleanup )
( setopt whitespace-line-column nil
2024-09-02 12:15:55 -04:00
whitespace-style ' ( lines-char
2024-08-20 17:33:23 -04:00
missing-newline-at-eof
space-after-tab
space-before-tab
tabs
trailing ) )
:hook
( ( conf-mode
prog-mode
text-mode ) . whitespace-mode ) )
2023-08-10 00:59:36 -04:00
2024-08-20 17:33:23 -04:00
;;; Packages:
2023-08-10 00:59:36 -04:00
2024-10-06 00:51:46 -04:00
;; `other-window' replacement
( use-package ace-window
:commands ( ace-window )
:bind ( " C-c w " . ace-window ) )
2024-08-20 17:33:23 -04:00
;; Shows current/total matches in mode line
( use-package anzu
:config ( global-anzu-mode )
:defer 3 )
2023-08-10 00:59:36 -04:00
2024-08-20 17:33:23 -04:00
;; Auto-format
( use-package apheleia
:defer t )
2023-08-10 00:59:36 -04:00
2024-10-06 00:51:46 -04:00
( use-package biblio
:after ( ebib )
:config ( setopt biblio-bibtex-use-autokey t ) )
2024-08-20 17:33:23 -04:00
;; Extensions for `completion-at-point'
( use-package cape
:bind ( " M-p " . cape-prefix-map ) )
2023-08-10 00:59:36 -04:00
2024-10-06 00:51:46 -04:00
;; TODO: pick a theme
2024-08-20 17:33:23 -04:00
;; Catppuccin theme
( use-package catppuccin-theme
2024-09-02 12:15:55 -04:00
:disabled
2023-08-10 00:59:36 -04:00
:config
2024-09-02 12:15:55 -04:00
( setopt catppuccin-flavor 'macchiato )
;; (catppuccin-reload)
;; (load-theme 'catppuccin t)
)
2023-08-10 00:59:36 -04:00
2024-08-26 16:43:30 -04:00
;; C/C++ formatting
;; Ad hoc format file: clang-format -style=webkit -dump-config > .clang-format
( use-package clang-format
:commands ( clang-format clang-format-buffer clang-format-region )
:config ( setopt clang-format-fallback-style " webkit "
clang-format-style " file " ) )
2023-08-10 00:59:36 -04:00
;; Search and navigation
( use-package consult
:bind ( ;; C-c bindings in `mode-specific-map'
( " C-c M-x " . consult-mode-command )
( " C-c h " . consult-history )
( " C-c k " . consult-kmacro )
( " C-c m " . consult-man )
( " C-c i " . consult-info )
( [ remap Info-search ] . consult-info )
;; C-x bindings in `ctl-x-map'
( " C-x M-: " . consult-complex-command ) ; orig. repeat-complex-command
( " C-x b " . consult-buffer ) ; orig. switch-to-buffer
( " C-x 4 b " . consult-buffer-other-window ) ; orig. switch-to-buffer-other-window
( " C-x 5 b " . consult-buffer-other-frame ) ; orig. switch-to-buffer-other-frame
( " C-x r b " . consult-bookmark ) ; orig. bookmark-jump
( " C-x p b " . consult-project-buffer ) ; orig. project-switch-to-buffer
( " C-x M-r " . consult-recent-file )
;; Custom M-# bindings for fast register access
( " M-# " . consult-register-load )
( " M-' " . consult-register-store ) ; orig. abbrev-prefix-mark (unrelated)
( " C-M-# " . consult-register )
;; Other custom bindings
( " M-y " . consult-yank-pop ) ; orig. yank-pop
;; M-g bindings in `goto-map'
( " M-g e " . consult-compile-error )
( " M-g f " . consult-flymake ) ; Alternative: consult-flycheck
( " M-g g " . consult-goto-line ) ; orig. goto-line
( " M-g M-g " . consult-goto-line ) ; orig. goto-line
( " M-g o " . consult-outline ) ; Alternative: consult-org-heading
( " M-g m " . consult-mark )
( " M-g k " . consult-global-mark )
( " M-g i " . consult-imenu )
( " M-g I " . consult-imenu-multi )
;; M-s bindings in `search-map'
( " M-s d " . consult-find )
( " M-s D " . consult-locate )
( " M-s g " . consult-grep )
( " M-s G " . consult-git-grep )
( " M-s r " . consult-ripgrep )
( " M-s l " . consult-line )
( " M-s L " . consult-line-multi )
( " M-s k " . consult-keep-lines )
( " M-s u " . consult-focus-lines )
;; Isearch integration
( " M-s e " . consult-isearch-history )
:map isearch-mode-map
( " M-e " . consult-isearch-history ) ; orig. isearch-edit-string
( " M-s e " . consult-isearch-history ) ; orig. isearch-edit-string
( " M-s l " . consult-line ) ; needed by consult-line to detect isearch
( " M-s L " . consult-line-multi ) ; needed by consult-line to detect isearch
;; Minibuffer history
:map minibuffer-local-map
( " M-s " . consult-history ) ; orig. next-matching-history-element
2024-08-26 16:43:30 -04:00
( " M-r " . consult-history )
:map as/org-prefix-map ; orig. previous-matching-history-element
( " h " . consult-org-heading )
( " a " . consult-org-agenda ) )
:config
( setopt consult-narrow-key " < " )
2024-08-20 17:33:23 -04:00
:init
;; Register formatting
( setopt register-preview-delay 0.6
register-preview-function #' consult-register-format )
;; Register preview window
( advice-add #' register-preview :override #' consult-register-window )
;; Select xref locations with preview
( setopt xref-show-xrefs-function #' consult-xref
xref-show-definitions-function #' consult-xref ) )
2023-08-10 00:59:36 -04:00
2024-08-26 16:43:30 -04:00
( use-package consult-dir
:after ( consult )
:bind ( ( " C-x C-d " . consult-dir )
:map vertico-map
( " C-x C-d " . consult-dir )
( " C-x C-j " . consult-dir-jump-file ) ) )
2024-08-20 17:33:23 -04:00
;; UI for the workspace/symbols procedure calls
( use-package consult-eglot
:after ( eglot )
:bind
( :map eglot-mode-map
2024-10-06 00:51:46 -04:00
( " C-c e s " . consult-eglot-symbols ) ) )
2023-08-10 00:59:36 -04:00
2024-10-06 00:51:46 -04:00
;; In-buffer completion with popup menu
2024-08-20 17:33:23 -04:00
( use-package company
2024-09-02 12:15:55 -04:00
:disabled
2024-08-20 17:33:23 -04:00
:bind
( :map company-active-map
( " RET " . nil )
( " [return] " . nil )
( " TAB " . company-complete-selection )
( " <tab> " . company-complete-selection )
( " C-n " . company-select-next )
( " C-p " . company-select-previous ) )
:config
( setopt company-global-modes ' ( not gud-mode not comint-mode )
company-tooltip-align-annotations t )
:hook ( prog-mode . company-mode ) )
2024-10-06 00:51:46 -04:00
;; In-buffer completion with popup menu
2023-08-10 00:59:36 -04:00
( use-package corfu
2023-08-28 13:02:51 -04:00
:config
2024-10-06 00:51:46 -04:00
( advice-add 'eglot-completion-at-point :around #' cape-wrap-buster )
( advice-add 'eglot-completion-at-point :around #' cape-wrap-noninterruptible )
( setopt corfu-auto nil
corfu-cycle t
corfu-preview-current nil )
2023-08-10 00:59:36 -04:00
( global-corfu-mode )
2024-10-06 00:51:46 -04:00
( corfu-history-mode )
2023-08-30 03:38:04 -04:00
( corfu-popupinfo-mode )
2024-08-20 17:33:23 -04:00
:defer 3
:ensure ( corfu :files ( :defaults " extensions/* " ) ) )
2024-10-06 00:51:46 -04:00
( use-package ebib
;;; Functions:
;; ebib-list-recent ; list entries added within the given # of days
;; ebib-download-url ; attempt to download file, rename, and save to target directory, filename determined by `ebib-name-transform-function'
;; ebib-import-file ; import a local file, file is renamed and moved, works for more than pdf, name deterined by `ebib-name-transform-function'
;;; ebib-biblio
;; ebib-biblio-selection-import ; function to import entry from biblio into ebib
;; ebib-biblio-import-doi ; function to import an entry while in ebib UI, can also choose different key
;;; keymaps
;; ebib-index-mode-map
;; ebib-entry-mode-map
;; ebib-strings-mode-map
;; ebib-multiline-mode-map
;; ebib-search-map
;; ebib-filters-map
;; ebib-keywords-map
;; ebib-reading-list-map
;; ebib-log-mode-map
:commands ( ebib )
2024-09-02 12:15:55 -04:00
:config
2024-10-06 00:51:46 -04:00
;; ebib-autogenerate-keys ; default t
( setopt ebib-bibtex-dialect 'biblatex
ebib-use-timestamp t ; create timestamp when entry added to db, note that "When importing or exporting entries, existing timestamps are overwritten."
ebib-filters-default-file ( expand-file-name " ebib-filters " user-emacs-directory ) ; file location to save filters
ebib-allow-identical-fields t ; merge repeated fields into one, separated by `ebib-keywords-separator'
ebib-file-associations ' ( ( " pdf " . nil )
( " ps " . " gs " ) ) ; specify which programs to use for which file types, or remove to open in emacs
ebib-import-target-directory " ~/Nextcloud/Library/ " ; set directory for `ebib-download-url' and `ebib-import-file'
;; ebib-default-directory "~/Nextcloud/Library/"; "This mainly determines which directory is the default directory when reading a file name from the user"
ebib-preload-bib-files ' ( " ~/Nextcloud/Library/bib/library.bib " ) ; autoload list of .bib files when started
;; ebib-bib-search dirs ; specify directory to search for multiple bib files when starting
;; ebib-extra-fields ; probably not needed
;;; UI
;; ebib-index-columns ; change displayed UI fields
;; ebib-field-transformation-functions ; new/change UI fields
;; ebib-field-sort-functions-alist ; customize UI sorting
;; ebib-edit-fields-functions ; disable/enable completion for different UI fields
;; ebib-multiline-display-function ; customize multiline values in UI
;; ebib-multiline-display-max-lines ; customize multiline values in UI
;; ebib-hidden-fields ; control which UI fields are hidden
;; ebib-save-indent-as-bibtex ; spaces instead of tabs in bib files, uses value of `bibtex-entry-offset' and `bibtex-field-indentation' to compute # of spaces
;; ebib-biblatex-ineritances ; customize biblatex inheritance
;;; Editing
;; ebib-save-xrefs-first ; must be enabled for cross-referencing to work, unless sort order changed?
;; ebib-sort-order ; change sort order of bib file - default is by key - make sure to unset `ebib-save-xrefs-first'
;; ebib-multiline-major-mode ; customize major mode for `ebib-multiline-edit-mode'
;; ebib-citation-commands ; might need to customize if using BibTex, which I'm not
;; ebib-citations-insert-multiple ; enable adding multiple citations at once, likely not needed
;; ebib-filters-ignore-case ; case-insensitive search filters are default
;;; Downloading/Filenames
;; ebib-name-transform-function ; modify file name that ebib searches for when associating a file with an entry
;; ebib-url-download-transformations ; sets how URLs are converted when attempting to download
;;; Notes
;; ebib-notes-storage 'multiple-notes-per-file ; probabably set to `multiple-notes-per-file' for org?
;; ebib-notes-locations ; files/directories containing notes
;; ebib-notes-default-file ; not used if creating note via org capture, but can still be set
;;; Org-capture
;; ebib-notes-use-org-capture ; set to desired keybind for ebib to skip org capture selection and use the one specified
;; ebib-org-capture ; function to call org capture from ebib
;;; Reading list
;; ebib-reading-list-file ; location of reading list
;; ebib-reading-list-todo-marker ; change default todo state for reading list items
;; ebib-reading-list-template ; change format of reading list items, available options in `ebib-reading-list-template-specifiers'
;; ebib-reading-list-add-item-function ; change where new items should be added
;; ebib-reading-list-remove-item ; by default only set to `ebib-reading-list-mark-item-as-done' - doesn't actually remove anything
;;; Keywords
;; ebib-keywords ; specify named keywords always available for completion
;;; Display options
;; ebib-windows ; customization group to change display
;;; Copying from ebib
;; ebib-reference-templates and ebib-citation-template ; change how entries are copied into kill ring
;;; org-ebib
;; org-ebib-link-type 'multiple-notes-per-file ; specify type of link produced by `org-store-link' on bib entries
)
)
2024-09-02 12:15:55 -04:00
2024-10-06 00:51:46 -04:00
( use-package ebib-biblio
:after ( ebib biblio )
:bind
( :map ebib-index-mode-map
( " B " . ebib-biblio-import-doi ) )
( :map biblio-selection-mode-map
( " e " . ebib-biblio-selection-import ) )
:ensure nil )
2024-09-02 12:15:55 -04:00
2024-08-20 17:33:23 -04:00
;; Use `emacs-lsp-booster' with `Eglot'
( use-package eglot-booster
:after eglot
:config ( eglot-booster-mode )
:ensure ( eglot-booster :host github :repo " jdtsmith/eglot-booster " ) )
;; Command menu for items around point
2024-08-26 16:43:30 -04:00
( use-package embark
2024-08-20 17:33:23 -04:00
:bind
( ( " C-. " . embark-act )
( " C-; " . embark-dwim )
( " C-h B " . embark-bindings ) )
:config
;; Hide the Embark live/completions buffer mode line
2024-10-06 00:51:46 -04:00
( add-to-list 'display-buffer-alist ' ( " \\ ` \\ *Embark Collect \\ (Live \\ |Completions \\ ) \\ * "
nil
( window-parameters ( mode-line-format . none ) ) ) )
2024-08-20 17:33:23 -04:00
:defer 3
:init ( setopt prefix-help-command #' embark-prefix-help-command ) )
2024-10-06 00:51:46 -04:00
;; Integration between `embark' and `consult'
2024-08-20 17:33:23 -04:00
( use-package embark-consult
:hook ( embark-collect-mode . consult-preview-at-point-mode ) )
2024-08-26 16:43:30 -04:00
;; Startup screen
( use-package enlight
:after ( grid )
:config
( setopt
enlight-content
( grid-get-row
` ( , ( enlight-menu
' ( ( " Files "
( " Find File " find-file " f " )
( " Recent Files " consult-recent-file " r " )
( " Projects " project-switch-project " p " )
2024-10-06 00:51:46 -04:00
( " Treemacs " treemacs " t " ) ) ) )
2024-08-26 16:43:30 -04:00
" "
, ( enlight-menu
' ( ( " Org "
2024-10-06 00:51:46 -04:00
( " My Agenda " ( org-agenda nil " y " ) " y " )
( " Work Agenda " ( org-agenda nil " w " ) " w " )
2024-08-26 16:43:30 -04:00
( " Time blocking " org-timeblock " b " )
( " Match Tags " ( org-agenda nil " m " ) " m " ) ) ) )
" "
, ( enlight-menu
` ( ( " Settings "
( " Elpaca " elpaca-manager " L " )
( " Emacs "
( progn
( find-file , user-init-file ) )
" I " )
( " Enlight "
( progn
( find-file , user-init-file )
( goto-char ( point-min ) )
( search-forward " use-package enlight " ) )
" E " )
( " Org "
( progn
( find-file , ( replace-regexp-in-string " init.el " " lisp/init-org.el " user-init-file ) ) )
" O " ) ) ) ) ) ) )
( enlight-open ) )
2024-08-20 17:33:23 -04:00
;; Correction functions for `flyspell'
( use-package flyspell-correct
:after ( flyspell )
:bind
( :map flyspell-mode-map
( " C-M-. " . flyspell-correct-wrapper ) ) )
2023-08-28 13:02:51 -04:00
2024-08-26 16:43:30 -04:00
;; Grid for `enlight'
( use-package grid
:ensure ( :host github :repo " ichernyshovvv/grid.el " ) )
2024-08-20 17:33:23 -04:00
;; Highlight keywords
( use-package hl-todo
:bind
( :map hl-todo-mode-map
2024-10-06 00:51:46 -04:00
( " C-c C-t p " . hl-todo-previous )
( " C-c C-t n " . hl-todo-next )
( " C-c C-t o " . hl-todo-occur )
( " C-c C-t i " . hl-todo-insert ) )
2024-08-20 17:33:23 -04:00
:config
( setopt hl-todo-highlight-punctuation " :!? "
hl-todo-keyword-faces ' ( ( " DEBUG " warning bold )
( " HACK " warning bold )
( " FIXME " error bold )
2024-10-06 00:51:46 -04:00
( " NOTE " homoglyph italic )
( " REVIEW " homoglyph italic )
( " TODO " homoglyph bold ) ) )
2024-08-20 17:33:23 -04:00
:ensure ( hl-todo :depth nil )
:hook ( prog-mode . hl-todo-mode ) )
2024-10-06 00:51:46 -04:00
;; Search `hl-todo' buffers with `consult'
( use-package consult-todo
:after ( hl-todo )
:bind
( :map hl-todo-mode-map
( " C-c C-t c " . consult-todo )
( " C-c C-t C-c " . consult-todo-all ) ) )
2024-08-20 17:33:23 -04:00
;; Icons for `corfu'
2023-08-10 00:59:36 -04:00
( use-package kind-icon
2024-08-20 17:33:23 -04:00
:disabled
2023-08-28 13:02:51 -04:00
:after ( corfu )
2024-08-20 17:33:23 -04:00
:config
2024-10-06 00:51:46 -04:00
;; Using nerd icons below
;; (add-to-list 'corfu-margin-formatters #'kind-icon-margin-formatter)
2024-08-20 17:33:23 -04:00
( setopt kind-icon-default-face 'corfu-default ) )
2024-06-11 07:33:21 -04:00
2023-08-10 00:59:36 -04:00
;; Git
2024-10-06 00:51:46 -04:00
;; Required by `magit' for menus
( use-package transient
2024-08-20 17:33:23 -04:00
:defer t )
2023-08-10 00:59:36 -04:00
( use-package magit
2023-08-30 03:38:04 -04:00
:bind ( " C-M-; " . magit-status )
2024-08-20 17:33:23 -04:00
:config
( setopt magit-display-buffer-function #' magit-display-buffer-same-window-except-diff-v1
2024-08-26 16:43:30 -04:00
transient-history-file ( expand-file-name " transient-history " xdg_cache_home ) ) )
2023-08-10 00:59:36 -04:00
2024-10-06 00:51:46 -04:00
;; Show `hl-todo' keywords in `magit' status buffers
2024-08-20 17:33:23 -04:00
( use-package magit-todos
:hook ( magit-mode . magit-todos-mode ) )
2023-08-10 00:59:36 -04:00
2024-08-20 17:33:23 -04:00
;; Better annotations
( use-package marginalia
:config ( marginalia-mode )
:defer 1 )
2023-08-10 00:59:36 -04:00
2024-10-06 00:51:46 -04:00
;; File format/markup support
2024-08-20 17:33:23 -04:00
( use-package markdown-mode
2024-10-06 00:51:46 -04:00
:bind
( :map markdown-mode-map
( " C-M-i " . fill-paragraph ) )
:commands ( markdown-mode ) )
2023-08-10 00:59:36 -04:00
2024-08-20 17:33:23 -04:00
;; Better C++ font locking
( use-package modern-cpp-font-lock
:hook ( c++-ts-mode . modern-c++-font-lock-mode ) )
2023-08-10 00:59:36 -04:00
2024-08-20 17:33:23 -04:00
;; Mode line
( use-package moody
:config
( setq x-underline-at-descent-line t )
( moody-replace-eldoc-minibuffer-message-function )
( moody-replace-mode-line-buffer-identification )
( moody-replace-mode-line-front-space )
( moody-replace-vc-mode )
:defer 1 )
2023-08-10 00:59:36 -04:00
2024-10-06 00:51:46 -04:00
;; Menu for minor modes in `minor-mode-list'
2024-08-20 17:33:23 -04:00
( use-package minions
:after ( moody )
:config ( minions-mode ) )
2023-08-10 00:59:36 -04:00
2024-10-06 00:51:46 -04:00
;; Nerd icons for various modes & packages
2024-08-20 17:33:23 -04:00
( use-package nerd-icons
:defer 1 )
2023-08-10 00:59:36 -04:00
2024-08-20 17:33:23 -04:00
( use-package nerd-icons-completion
:after ( nerd-icons marginalia )
:config ( nerd-icons-completion-mode )
:hook ( marginalia-mode . nerd-icons-completion-marginalia-setup ) )
2023-08-28 13:02:51 -04:00
2024-08-20 17:33:23 -04:00
( use-package nerd-icons-corfu
:after ( nerd-icons corfu )
2024-10-06 00:51:46 -04:00
:config
( add-to-list 'corfu-margin-formatters #' nerd-icons-corfu-formatter ) )
2023-08-28 13:02:51 -04:00
2024-08-20 17:33:23 -04:00
( use-package nerd-icons-dired
:hook ( dired-mode . nerd-icons-dired-mode ) )
2023-08-28 13:02:51 -04:00
2024-08-20 17:33:23 -04:00
( use-package nerd-icons-ibuffer
:hook ( ibuffer-mode . nerd-icons-ibuffer-mode ) )
2023-08-28 13:02:51 -04:00
2024-10-06 00:51:46 -04:00
;; TODO: pick a theme
( use-package nimbus-theme
:config ( load-theme 'nimbus ) )
;; EPUB
( use-package nov
:config ( setopt nov-text-width 100 )
:mode ( " \\ .epub \\ ' " . nov-mode ) )
2024-08-20 17:33:23 -04:00
;; Completion style
( use-package orderless
:config
( setopt completion-styles ' ( orderless basic )
completion-category-overrides ' ( ( file ( styles basic partial-completion ) ) )
orderless-matching-styles ' ( orderless-regexp
2024-08-26 16:43:30 -04:00
orderless-literal
orderless-initialism ) )
2024-08-20 17:33:23 -04:00
:defer 1 )
2023-08-28 13:02:51 -04:00
2024-10-06 00:51:46 -04:00
;; Better PDF viewing and navigation
( use-package pdf-tools
:config
( setopt pdf-info-epdfinfo-program ( expand-file-name " pdf-tools/server/epdfinfo " elpaca-builds-directory )
pdf-view-resize-factor 1.1
pdf-view-display-size 'fit-page )
:ensure ( pdf-tools :pre-build ( " ./server/autobuild " ) :files ( :defaults ( " lisp/* " " server/epdfinfo " ) ) )
:hook ( pdf-view-mod . pdf-view-midnight-minor-mode )
:mode ( " \\ .pdf \\ ' " . pdf-view-mode ) )
;; Project Management - disabled, see `project' built-in package
2024-08-20 17:33:23 -04:00
( use-package projectile
:disabled
:bind ( " C-c p " . projectile-command-map )
:config
2024-08-26 16:43:30 -04:00
( setopt projectile-known-projects-file ( expand-file-name " projectile-bookmarks " xdg_cache_home )
2024-08-20 17:33:23 -04:00
projectile-project-search-path ' ( ( " ~/Nextcloud/Projects/src/ " . 2 ) ) )
2024-10-06 00:51:46 -04:00
( add-to-list 'projectile-globally-ignored-directories " *node_modules " )
2024-08-20 17:33:23 -04:00
( projectile-mode ) )
2023-08-10 00:59:36 -04:00
;; Visualize color names
( use-package rainbow-mode
2024-07-09 08:56:24 -04:00
:hook ( ( conf-mode
prog-mode
toml-ts-mode ) . rainbow-mode ) )
2023-08-10 00:59:36 -04:00
2024-08-20 17:33:23 -04:00
;; `gud' rewrite with additional features
( use-package realgud
:defer t )
;; `realgud' front-end for LLDB
( use-package realgud-lldb
:defer t )
( use-package rust-mode
:init ( setopt rust-mode-treesitter-derive t )
:commands ( rust-mode ) )
2024-10-06 00:51:46 -04:00
( use-package treemacs
:defer t
:commands ( treemacs )
:config
( setopt treemacs-eldoc-display 'simple
treemacs-hide-dot-git-directory nil
treemacs-is-never-other-window t
treemacs-persist-file ( expand-file-name " treemacs-persist " xdg_cache_home )
treemacs-text-scale 2
treemacs-width-is-initially-locked t )
( add-to-list 'treemacs-litter-directories " ./zig-cache " )
( treemacs-resize-icons 22 )
( treemacs-follow-mode t )
( treemacs-filewatch-mode t )
( treemacs-fringe-indicator-mode 'always )
( treemacs-git-commit-diff-mode t )
( treemacs-git-mode 'deferred )
;; (treemacs-hide-gitignored-files-mode nil)
( treemacs-indent-guide-mode )
:init
( bind-keys :prefix-map as/treemacs-prefix-map
:prefix " C-c t "
( " 0 " . treemacs-select-window )
( " 1 " . treemacs-delete-other-windows )
( " t " . treemacs )
( " d " . treemacs-select-directory )
( " B " . treemacs-bookmark )
( " C-f " . treemacs-find-file )
( " M-t " . treemacs-find-tag ) ) )
( use-package treemacs-magit
:after ( treemacs magit ) )
2024-08-20 17:33:23 -04:00
;; Automatically download tree-sitter grammars
2023-08-10 00:59:36 -04:00
( use-package treesit-auto
2024-06-11 07:33:21 -04:00
:defer 1
:config
2024-08-20 17:33:23 -04:00
( setopt treesit-auto-install t )
( setq as/c-tsauto-config
( make-treesit-auto-recipe
:lang 'c
:ts-mode 'c-ts-mode
:remap 'c-mode
:url " https://github.com/tree-sitter/tree-sitter-c "
:revision " v0.20.7 "
:ext " \\ .c \\ ' " ) )
( setq as/cpp-tsauto-config
2024-07-09 08:56:24 -04:00
( make-treesit-auto-recipe
:lang 'cpp
:ts-mode 'c++-ts-mode
:remap 'c++-mode
:url " https://github.com/tree-sitter/tree-sitter-cpp "
:revision " v0.21.0 "
:ext " \\ .cpp \\ ' " ) )
2024-10-06 00:51:46 -04:00
( add-to-list 'treesit-auto-recipe-list as/c-tsauto-config )
( add-to-list 'treesit-auto-recipe-list as/cpp-tsauto-config )
;; (push as/c-tsauto-config treesit-auto-recipe-list)
;; (push as/cpp-tsauto-config treesit-auto-recipe-list)
2024-06-11 07:33:21 -04:00
( treesit-auto-add-to-auto-mode-alist 'all )
2024-08-20 17:33:23 -04:00
( global-treesit-auto-mode ) )
2023-08-10 00:59:36 -04:00
2024-08-20 17:33:23 -04:00
;; Better undo/redo
( use-package undo-fu
:bind ( ( " C-z " . undo-fu-only-undo )
2024-10-06 00:51:46 -04:00
( " C-S-z " . undo-fu-only-redo ) )
:defer 3 )
2024-05-18 13:02:27 -04:00
2024-08-20 17:33:23 -04:00
( use-package undo-fu-session
:after ( undo-fu )
2023-08-10 00:59:36 -04:00
:config
2024-08-20 17:33:23 -04:00
( setopt undo-fu-session-incompatible-files ' ( " /COMMIT_EDITMSG \\ ' " " /git-rebase-todo \\ ' " )
undo-fu-session-directory ( concat xdg_cache_home " undo-fu-session/ " ) )
( undo-fu-session-global-mode ) )
2023-08-28 13:02:51 -04:00
2024-08-20 17:33:23 -04:00
;; Mini-buffer completion UI
( use-package vertico
:config
( setopt vertico-cycle t
vertico-count 10
vertico-resize t
2024-10-06 00:51:46 -04:00
vertico-scroll-margin 1 )
2024-08-20 17:33:23 -04:00
:init ( vertico-mode ) )
;; Web and SSG
2024-06-11 07:33:21 -04:00
( define-derived-mode astro-mode web-mode " astro " )
2023-08-28 13:02:51 -04:00
( use-package web-mode
2024-08-20 17:33:23 -04:00
:config
( setopt web-mode-attribute-indent-offset 2
web-mode-code-indent-offset 2
web-mode-css-indent-offset 2
web-mode-markup-indent-offset 2
web-mode-enable-front-matter-block t
web-mode-engines-alist ' ( ( " blade " . " \\ .blade \\ . " )
( " razor " . " \\ .cshtml \\ ' " ) ) )
2023-08-28 13:02:51 -04:00
:mode
2024-06-11 07:33:21 -04:00
( " \\ .astro \\ ' " . astro-mode )
( " \\ . \\ (cshtml \\ |html? \\ |razor \\ ) \\ ' " . web-mode ) )
2023-08-10 00:59:36 -04:00
2024-08-20 17:33:23 -04:00
;; Show keybind hints
( use-package which-key
:config
( setopt which-key-idle-delay 0.3
;; which-key-sort-order 'which-key-description-order
which-key-side-window-max-width 0.33 )
( which-key-mode )
:defer 1 )
;; Expand abbreviations to templates
( use-package yasnippet
:bind
2024-10-06 00:51:46 -04:00
( ;; :map yas-minor-mode-map ; need to enable mode with something other than `:commands'
( " C-c y i " . yas-insert-snippet )
( " C-c y v " . yas-visit-snippet-file ) )
:config
( yas-reload-all ) ; needed if not using `yas-global-mode'
( yas-minor-mode ) )
2024-08-20 17:33:23 -04:00
( use-package yasnippet-snippets
:after ( yasnippet ) )
( use-package consult-yasnippet
2024-10-06 00:51:46 -04:00
:after ( consult yasnippet )
2024-08-20 17:33:23 -04:00
:bind
( :map yas-minor-mode-map
( " C-c y c " . consult-yasnippet ) ) )
;; YAML
( use-package yaml-pro
:hook ( yaml-ts-mode . yaml-pro-ts-mode ) )
2023-08-10 00:59:36 -04:00
;; Zig
2024-08-20 17:33:23 -04:00
( use-package reformatter ; required for `zig-format' functions
:after ( zig-mode ) )
2023-08-10 00:59:36 -04:00
( use-package zig-mode
2023-09-04 03:42:08 -04:00
:commands ( zig-mode )
2024-01-13 01:07:16 -05:00
:config
( defun zig-compile ( )
2024-10-06 00:51:46 -04:00
" Save buffer and compile using ` zig build ` . Overrides `zig-compile' in 'zig-mode.el'. "
2024-01-13 01:07:16 -05:00
( interactive )
( save-buffer )
( zig--run-cmd " build " ) )
2024-10-06 00:51:46 -04:00
( setopt fill-column 100
zig-format-on-save nil ) )
2023-08-10 00:59:36 -04:00
2024-10-06 00:51:46 -04:00
( add-to-list 'load-path " ~/.config/emacs/lisp/ " )
2024-08-20 17:33:23 -04:00
( require 'init-org )
2024-10-06 00:51:46 -04:00
2023-08-10 00:59:36 -04:00
;;; init.el ends here