From 456d426fe3f243cdc7eaee401641078dc20493b9 Mon Sep 17 00:00:00 2001 From: Joseph Ferano Date: Wed, 29 Mar 2023 15:48:59 +0700 Subject: [PATCH] Porting to elpaca. Mostly everything works. - evil-snipe broke - dashboard broke - kind of fixed issue with leader keymap --- .config/emacs/init.org | 1130 ++++++++++++++++++++-------------------- 1 file changed, 574 insertions(+), 556 deletions(-) diff --git a/.config/emacs/init.org b/.config/emacs/init.org index 6c59d79..67e401b 100644 --- a/.config/emacs/init.org +++ b/.config/emacs/init.org @@ -5,6 +5,14 @@ #+TOC: true ** Early Init +*** Filename handler alist +Skipping a bunch of regular expression searching in the file-name-handler-alist should improve start time. + +#+begin_src emacs-lisp +(defvar default-file-name-handler-alist file-name-handler-alist) +(setq file-name-handler-alist nil) +#+end_src + *** Garbage Collection The default Garbage Collector is triggered at 800 KB, way too conservative, let's bump to 512 MB. @@ -13,8 +21,6 @@ enabling `gcmh-mode'. Not resetting it will cause stuttering/freezes. #+begin_src emacs-lisp :tangle ./early-init.el ;; -*- lexical-binding: t -*- -(defvar default-file-name-handler-alist file-name-handler-alist) -(setq file-name-handler-alist nil) (setq gc-cons-threshold (expt 2 32)) (add-hook 'emacs-startup-hook @@ -43,25 +49,17 @@ Disabling these classic visual options during early-init seems to net a 0.04 ms (menu-bar-mode -1) (tooltip-mode -1) #+end_src -*** Straight.el Prep +*** Enhancements -Disable package.el, since we will be using straight.el. According to the straight.el +Disable package.el, since we will be using elpaca.el. According to the elpaca.el documentation; -#+BEGIN_QUOTE -While it is technically possible to use both package.el and straight.el at the same time, there is -no real reason to, and it might result in oddities like packages getting loaded more than once. -#+END_QUOTE - -Either way, if you need to quickly install a package for testing, you can just run -=(straight-use-package)= interactively. - #+BEGIN_SRC emacs-lisp :tangle ./early-init.el (setq package-enable-at-startup nil) #+END_SRC -*** Enhancements -Prioritize old byte-compiled source files over newer sources. It saves us a little IO time to skip all the mtime checks on each lookup. +Prioritize old byte-compiled source files over newer sources. It saves us a little IO time to skip +all the mtime checks on each lookup. #+begin_src emacs-lisp :tangle ./early-init.el (setq load-prefer-newer nil) @@ -76,6 +74,27 @@ Prioritize old byte-compiled source files over newer sources. It saves us a litt (setq server-name (format "Emacs-%d" (emacs-pid))) (add-hook 'after-init-hook #'server-start) #+end_src + +Prevent instructions on how to close an emacsclient frame. + +#+begin_src emacs-lisp +(setq server-client-instructions nil) +#+end_src + +Implicitly resizing the Emacs frame adds to init time. Fonts larger than the system default can +cause frame resizing, which adds to startup time. + +#+begin_src emacs-lisp +(setq frame-inhibit-implied-resize t) +#+end_src + +Ignore X resources. + +#+begin_src emacs-lisp +(advice-add #'x-apply-session-resources :override #'ignore) +#+end_src + + *** UTF-8 Support #+begin_src emacs-lisp :tangle ./early-init.el (setq default-input-method nil) @@ -87,30 +106,57 @@ Prioritize old byte-compiled source files over newer sources. It saves us a litt (set-terminal-coding-system 'utf-8) (set-selection-coding-system 'utf-8) (prefer-coding-system 'utf-8) +#+end_src + +Finish up +#+begin_src emacs-lisp +(provide 'early-init) ;;; early-init.el ends here #+end_src -** Straight.el - -For now, use [[https://github.com/radian-software/straight.el][straight.el]] until [[https://github.com/progfolio/elpaca -][elpaca]] is ready for production use. - -Then bootstrap +** Elpaca #+BEGIN_SRC emacs-lisp -;; -*- lexical-binding: t -*- + ;; -*- lexical-binding: t -*- +(defvar elpaca-installer-version 0.3) +(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" + :ref nil + :files (:defaults (:exclude "extensions")) + :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) + (condition-case-unless-debug err + (if-let ((buffer (pop-to-buffer-same-window "*elpaca-bootstrap*")) + ((zerop (call-process "git" nil buffer t "clone" + (plist-get order :repo) repo))) + ((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))) + (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)) + +(setq elpaca-queue-limit 30) -(defvar bootstrap-version) -(let ((bootstrap-file - (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory)) - (bootstrap-version 6)) - (unless (file-exists-p bootstrap-file) - (with-current-buffer - (url-retrieve-synchronously - "https://raw.githubusercontent.com/radian-software/straight.el/develop/install.el" - 'silent 'inhibit-cookies) - (goto-char (point-max)) - (eval-print-last-sexp))) - (load bootstrap-file nil 'nomessage)) #+END_SRC ** Benchmarking @@ -118,7 +164,7 @@ This is commented out since it adds ever so slightly to init time, but keep it a need to benchmark slow init times later. #+begin_src emacs-lisp :tangle no -(straight-use-package 'benchmark-init) +(elpaca 'benchmark-init) (require 'benchmark-init) (add-hook 'after-init-hook 'benchmark-init/deactivate) #+end_src @@ -129,7 +175,7 @@ need to benchmark slow init times later. (setq vc-follow-symlinks t) ; Visit real file when editing a symlink without prompting. (global-auto-revert-mode t) ; Revert buffer's file when the file changes on disk -;; (setq confirm-kill-emacs 'y-or-n-p) +(setq confirm-kill-emacs 'y-or-n-p) (require 'recentf) (recentf-mode t) @@ -163,50 +209,77 @@ I don't even know how you resume from GUI mode, we'll find a use for this keybin (when (display-graphic-p) (global-unset-key (kbd "C-z"))) #+end_src + +This shows up when building Emacs; + +#+begin_quote +3. New Org version is loaded using straight.el package manager and + other package depending on Org is loaded before straight triggers + loading of the newer Org version. + + It is recommended to put + + (elpaca 'org) + + early in the config. Ideally, right after the straight.el + bootstrap. Moving ‘use-package’ :straight declaration may not be + sufficient if the corresponding ‘use-package’ statement is + deferring the loading. +#+end_quote ** Visuals +*** Initial Buffer +#+begin_src emacs-lisp +(setq initial-buffer-choice "~/.config/emacs/init.org") +#+end_src *** Dashboard Use Dashboard.el. First load `all-the-icons` for nicer rendering -#+begin_src emacs-lisp -;; (straight-use-package 'all-the-icons) -(straight-use-package 'dashboard) -(dashboard-setup-startup-hook) -(setq dashboard-items '((recents . 6) - (projects . 5) - (bookmarks . 5))) -(setq dashboard-startup-banner 'logo) -(setq dashboard-center-content t) -(setq dashboard-set-file-icons t) -(setq dashboard-set-navigator t) -(setq dashboard-set-heading-icons t) -(setq dashboard-projects-backend 'project-el) -(add-hook 'dashboard-mode-hook (lambda () - (setq-local line-spacing 12) - (dashboard-jump-to-recents))) -(defun joe/launch-dashboard () - "Jump to the dashboard buffer, if doesn't exists create one." - (interactive) - (switch-to-buffer dashboard-buffer-name) - (dashboard-mode) - (dashboard-insert-startupify-lists)) +#+begin_src emacs-lisp :tangle no +;; (elpaca 'all-the-icons) +(elpaca (dashboard :ref "554dc6f") +;; (elpaca 'dashboard + (dashboard-setup-startup-hook) + (setq dashboard-items '((recents . 6) + (projecss . 5) + (bookmarks . 5))) + (setq dashboard-startup-banner 'logo) + (setq dashboard-center-content t) + (setq dashboard-set-file-icons t) + (setq dashboard-set-navigator t) + (setq dashboard-set-heading-icons t) + (setq dashboard-projects-backend 'project-el) + + (add-hook 'dashboard-mode-hook + (lambda () + (setq-local line-spacing 12) + (dashboard-jump-to-recents))) + + (defun joe/launch-dashboard () + "Jump to the dashboard buffer, if doesn't exists create one." + (interactive) + (switch-to-buffer dashboard-buffer-name) + (dashboard-mode) + (dashboard-insert-startupify-lists))) #+end_src *** Olivetti #+begin_src emacs-lisp -(straight-use-package 'olivetti) +(elpaca 'olivetti (require 'olivetti) (setq olivetti-minimum-body-width 100) -(global-set-key (kbd "C-x x o") 'olivetti-mode) +(global-set-key (kbd "C-x x o") 'olivetti-mode)) #+end_src *** Themes #+begin_src emacs-lisp ;; Small changes to my favorite themes -(straight-use-package - '(doom-themes :type git :host github :repo "doomemacs/themes" - :fork (:host github - :repo "JosephFerano/doom-themes"))) + +(elpaca + '(doom-themes :host github :repo "doomemacs/themes" + :remotes ("fork" :repo "JosephFerano/doom-themes")) + +(load-theme 'doom-nord-light)) (setq custom-safe-themes t) @@ -250,11 +323,8 @@ Setup other stuff (make-variable-buffer-local 'global-hl-line-mode) (dolist (mode '( dashboard-mode-hook org-mode-hook term-mode-hook eww-mode-hook vterm-mode-hook dirvish-directory-view-mode-hook - eshell-mode-hook dired-mode-hook shell-mode-hook magit-mode-hook compilation-mode-hook)) - (add-hook mode (lambda () (display-line-numbers-mode 0)))) -;; (dolist (mode '(dashboard-mode-hook org-mode-hook term-mode-hook eww-mode-hook vterm-mode-hook -;; eshell-mode-hook shell-mode-hook magit-mode-hook compilation-mode-hook)) -;; (add-hook mode (lambda () (display-line-numbers-mode 0)))) + eshell-mode-hook dired-mode-hook shell-mode-hook magit-mode-hook compilation-mode-hook)) + (add-hook mode (lambda () (display-line-numbers-mode 0)))) (set-window-margins nil 0) (setq-default right-fringe-width 10) @@ -278,13 +348,13 @@ Setup other stuff ;; Don’t compact font caches during GC, in case doom modeline gets laggy issue (setq inhibit-compacting-font-caches t) -(straight-use-package 'ligature) -(global-ligature-mode) +(elpaca 'ligature +(global-ligature-mode)) -(straight-use-package 'highlight-quoted) -(add-hook 'emacs-lisp-mode-hook 'highlight-quoted-mode) +(elpaca 'highlight-quoted +(add-hook 'emacs-lisp-mode-hook 'highlight-quoted-mode)) -(straight-use-package 'doom-modeline) +(elpaca 'doom-modeline (doom-modeline-mode) (doom-modeline-def-modeline 'main '(workspace-name bar modals bar window-number matches buffer-info remote-host buffer-position word-count selection-info) @@ -293,12 +363,12 @@ Setup other stuff ;; Set default mode-line (add-hook 'doom-modeline-mode-hook (lambda () - (doom-modeline-set-modeline 'main 'default))) + (doom-modeline-set-modeline 'main 'default)))) +;; TODO Likely not needed anymore (dolist (mode '(dired-mode-hook lsp-help-mode-hook fundamental-mode-hook)) (add-hook mode (lambda () (setq truncate-lines t)))) - #+end_src ** Text @@ -312,6 +382,7 @@ Setup other stuff (setq-default line-spacing 5) (setq indent-line-function #'indent-relative) +(set-default 'truncate-lines t) ;; (add-hook 'before-save-hook 'whitespace-cleanup) #+end_src ** Text Editor @@ -373,7 +444,7 @@ weren't working, until I randomly saw this in someone's init.el #+end_src *** Hydra #+begin_src emacs-lisp -(straight-use-package 'hydra) +(elpaca 'hydra (defhydra hydra-navigate (global-map "") "Window Navigation" @@ -384,16 +455,16 @@ weren't working, until I randomly saw this in someone's init.el ("y" joe/smooth-scroll-short-up "line up") ("n" next-line "line down") ("p" previous-line "line up") - ("M-r" move-to-window-line-top-bottom "Reposition cursor")) + ("M-r" move-to-window-line-top-bottom "Reposition cursor"))) #+end_src *** Multiple Cursors #+begin_src emacs-lisp -(straight-use-package 'multiple-cursors) +(elpaca 'multiple-cursors) #+end_src *** Meow #+begin_src emacs-lisp :tangle no -(straight-use-package 'meow) +(elpaca 'meow) (defun meow-setup () (setq meow-cheatsheet-layout meow-cheatsheet-layout-qwerty) (meow-motion-overwrite-define-key @@ -486,41 +557,49 @@ weren't working, until I randomly saw this in someone's init.el #+end_src *** Boon #+begin_src emacs-lisp :tangle no -(straight-use-package 'boon) -(require 'boon-qwerty) -(boon-mode) -(define-key boon-moves-map "h" 'backward-char) -(define-key boon-moves-map "j" 'next-line) -(define-key boon-moves-map "k" 'previous-line) -(define-key boon-moves-map "l" 'forward-char) -(define-key boon-moves-map "b" 'boon-smarter-backward) -(define-key boon-moves-map "w" 'boon-smarter-forward) -(define-key boon-moves-map "q" '("hop" . avy-goto-char-2)) -(define-key boon-command-map (kbd "C-k") #'joe/scroll-down-line) -(define-key boon-command-map (kbd "C-j") #'joe/scroll-up-line) +(defun joe/psp-scroll-down-half-page () + (interactive) + (pixel-scroll-precision-scroll-down-page (/ (window-pixel-height) 2))) +(defun joe/psp-scroll-up-half-page () + (interactive) + (pixel-scroll-precision-scroll-up-page (/ (window-pixel-height) 2))) -(define-key boon-command-map (kbd "C-d") #'View-scroll-half-page-forward) -(define-key boon-command-map (kbd "C-u") #'View-scroll-half-page-backward) +(elpaca 'boon + (require 'boon-qwerty) + (boon-mode) + (define-key boon-moves-map "h" 'backward-char) + (define-key boon-moves-map "j" 'next-line) + (define-key boon-moves-map "k" 'previous-line) + (define-key boon-moves-map "l" 'forward-char) + (define-key boon-moves-map "b" 'boon-smarter-backward) + (define-key boon-moves-map "w" 'boon-smarter-forward) + (define-key boon-moves-map "q" '("hop" . avy-goto-char-2)) + (define-key boon-command-map (kbd "C-k") #'joe/scroll-down-line) + (define-key boon-command-map (kbd "C-j") #'joe/scroll-up-line) -(defun joe/scroll-up-line () (interactive) (scroll-up-line 2)) -(defun joe/scroll-down-line () (interactive) (scroll-down-line 2)) + (define-key boon-command-map (kbd "C-d") #'joe/psp-scroll-down-half-page) + (define-key boon-command-map (kbd "C-u") #'joe/psp-scroll-up-half-page) -(define-key boon-moves-map "H" 'backward-paragraph) -(define-key boon-moves-map "L" 'forward-paragraph) -(define-key boon-moves-map "K" 'boon-smarter-upward) -(define-key boon-moves-map "J" 'boon-smarter-downward) + (defun joe/scroll-up-line () (interactive) (scroll-up-line 2)) + (defun joe/scroll-down-line () (interactive) (scroll-down-line 2)) -(define-key boon-moves-map "o" 'boon-open-next-line-and-insert) -(define-key boon-moves-map "O" 'boon-open-line-and-insert) + (define-key boon-moves-map "H" 'backward-paragraph) + (define-key boon-moves-map "L" 'forward-paragraph) + (define-key boon-moves-map "K" 'boon-smarter-upward) -(define-key boon-moves-map "i" 'boon-set-insert-like-state) -(define-key boon-moves-map "r" 'boon-replace-by-character) -(define-key boon-moves-map "y" 'boon-replace-by-character) -(define-key boon-moves-map "p" 'boon-splice) -(define-key boon-moves-map "y" 'boon-treasure-region) + (define-key boon-moves-map "J" 'boon-smarter-downward) -(define-key ctl-x-map "s" 'save-buffer) + (define-key boon-moves-map "o" 'boon-open-next-line-and-insert) + (define-key boon-moves-map "O" 'boon-open-line-and-insert) + + (define-key boon-moves-map "i" 'boon-set-insert-like-state) + (define-key boon-moves-map "r" 'boon-replace-by-character) + (define-key boon-moves-map "y" 'boon-replace-by-character) + (define-key boon-moves-map "p" 'boon-splice) + (define-key boon-moves-map "y" 'boon-treasure-region) + + (define-key ctl-x-map "s" 'save-buffer)) #+end_src *** Evil @@ -532,106 +611,102 @@ weren't working, until I randomly saw this in someone's init.el (setq evil-want-Y-yank-to-eol t) (setq evil-disable-insert-state-bindings t) (setq evil-echo-state nil) -(straight-use-package 'evil) -(straight-use-package 'evil-collection) -(evil-mode t) -(evil-collection-init) +(elpaca 'evil + (evil-mode t) -;; TODO: We need 3 bindings; 1.) close buffer 2.) close window 3.) close buffer and window -;; To disable a keybinding just bind it to nil -(evil-set-leader nil (kbd "C-SPC")) -(evil-set-leader 'normal (kbd "SPC")) + (evil-global-set-key 'insert (kbd "C-w") #'evil-delete-backward-word) + (evil-define-key 'normal 'global (kbd "q") 'avy-goto-word-0) -(evil-global-set-key 'insert (kbd "C-w") #'evil-delete-backward-word) -(evil-define-key 'normal 'global (kbd "q") 'avy-goto-word-0) + ;; vv to expand selection to line + (evil-global-set-key 'visual + (kbd "v") + (lambda () + (interactive) + (evil-first-non-blank) + (exchange-point-and-mark) + (evil-end-of-line))) -;; vv to expand selection to line -(evil-global-set-key 'visual - (kbd "v") - (lambda () - (interactive) - (evil-first-non-blank) - (exchange-point-and-mark) - (evil-end-of-line))) -(add-hook 'emacs-startup-hook - (lambda () - (evil-global-set-key 'normal (kbd "t") tab-prefix-map) - (evil-define-key 'normal 'global - (kbd "q") 'kill-buffer-and-window - (kbd "k") 'kill-this-buffer - (kbd "h") 'help-command - (kbd "hf") 'helpful-callable - (kbd "hv") 'helpful-variable - (kbd "hk") 'helpful-key - (kbd "ho") 'helpful-symbol - (kbd "hg") 'helpful-at-point - (kbd "fb") 'bookmark-jump - (kbd "fr") 'consult-recent-file - (kbd "ff") 'project-find-file - (kbd "fi") 'joe/edit-init - (kbd "bl") 'mode-line-other-buffer - (kbd "ba") 'consult-buffer - (kbd "bb") 'consult-project-buffer - (kbd "bi") 'ibuffer - (kbd "bm") 'joe/toggle-buffer-mode - (kbd "br") 'joe/revert-buffer-no-confirm - (kbd "gg") 'magit-status - (kbd "gc") 'magit-clone - (kbd "ss") 'joe/vterm-here - (kbd "sv") 'vterm - (kbd "Ba") 'joe/bookmark-set-and-save - (kbd "Bd") 'bookmark-delete - (kbd "mr") 'joe/compile-run - (kbd "mc") 'joe/compile-comp - (kbd "ct") 'consult-theme - (kbd "cl") 'consult-line - (kbd "ci") 'consult-imenu - (kbd "cy") 'consult-yank-from-kill-ring - (kbd "cg") 'consult-ripgrep - (kbd "cF") 'consult-find - (kbd "co") 'consult-outline))) + (defvar joe/evil-space-mode-map (make-sparse-keymap) + "High precedence keymap.") -;; (define-prefix-command 'evil-consult-map) -;; (define-key evil-consult-map "b" 'evil-window-bottom-right) -;; (define-key evil-consult-map "c" 'evil-window-delete) + (define-minor-mode joe/evil-space-mode + "Global minor mode for higher precedence evil keybindings." + :global t) -(defvar global-evil-leader-map (make-sparse-keymap)) -;; (evil-define-key 'normal 'global-evil-leader-map (kbd "SPC") 'evil-send-leader) + (joe/evil-space-mode) -(define-minor-mode global-evil-leader-mode - "Minor mode to make evil leader global" - :global t - :keymap global-evil-leader-map) -(global-evil-leader-mode) + (dolist (state '(normal visual insert)) + (evil-make-intercept-map + ;; NOTE: This requires an evil version from 2018-03-20 or later + (evil-get-auxiliary-keymap joe/evil-space-mode-map state t t) + state)) -;; (evil-define-key 'normal 'global (kbd "M-h") 'tab-line-switch-to-prev-tab) -;; (evil-define-key 'normal 'global (kbd "M-l") 'tab-line-switch-to-next-tab) + (evil-define-key 'normal joe/evil-space-mode-map + (kbd "SPC t") tab-prefix-map + (kbd "SPC p") project-prefix-map + (kbd "SPC q") 'kill-buffer-and-window + (kbd "SPC k") 'kill-this-buffer + (kbd "SPC h") 'help-command + (kbd "SPC hf") 'helpful-callable + (kbd "SPC hv") 'helpful-variable + (kbd "SPC hk") 'helpful-key + (kbd "SPC ho") 'helpful-symbol + (kbd "SPC hg") 'helpful-at-point + (kbd "SPC fb") 'bookmark-jump + (kbd "SPC fr") 'consult-recent-file + (kbd "SPC ff") 'project-find-file + (kbd "SPC fi") 'joe/edit-init + (kbd "SPC bl") 'mode-line-other-buffer + (kbd "SPC ba") 'consult-buffer + (kbd "SPC bb") 'consult-project-buffer + (kbd "SPC bi") 'ibuffer + (kbd "SPC bm") 'joe/toggle-buffer-mode + (kbd "SPC br") 'joe/revert-buffer-no-confirm + (kbd "SPC gg") 'magit-status + (kbd "SPC gc") 'magit-clone + (kbd "SPC ss") 'joe/vterm-here + (kbd "SPC sv") 'vterm + (kbd "SPC Ba") 'joe/bookmark-set-and-save + (kbd "SPC Bd") 'bookmark-delete + (kbd "SPC mr") 'joe/compile-run + (kbd "SPC mc") 'joe/compile-comp + (kbd "SPC ct") 'consult-theme + (kbd "SPC cl") 'consult-line + (kbd "SPC ci") 'consult-imenu + (kbd "SPC cy") 'consult-yank-from-kill-ring + (kbd "SPC cg") 'consult-ripgrep + (kbd "SPC cF") 'consult-find + (kbd "SPC co") 'consult-outline) -(straight-use-package 'evil-surround) -(global-evil-surround-mode t) + (define-key evil-window-map "u" #'winner-undo) + (define-key evil-window-map "U" #'winner-redo) -(straight-use-package 'evil-snipe) -(evil-snipe-override-mode t) + (defun joe/scroll-up-line () (interactive) (scroll-up-line 2)) + (defun joe/scroll-down-line () (interactive) (scroll-down-line 2)) + (evil-global-set-key 'normal (kbd "C-e") #'joe/scroll-up-line) + (evil-global-set-key 'normal (kbd "C-y") #'joe/scroll-down-line)) -(straight-use-package 'evil-commentary) -(evil-commentary-mode t) -(straight-use-package 'evil-goggles) -(evil-goggles-mode t) -(setq evil-goggles-duration 0.075) -(setq evil-goggles-pulse t) -(setq evil-goggles-async-duration 0.55) +(elpaca 'evil-collection + (evil-collection-init)) -(define-key evil-window-map "u" #'winner-undo) -(define-key evil-window-map "U" #'winner-redo) +(elpaca 'evil-surround + (global-evil-surround-mode t)) -(defun joe/scroll-up-line () (interactive) (scroll-up-line 2)) -(defun joe/scroll-down-line () (interactive) (scroll-down-line 2)) -(evil-global-set-key 'normal (kbd "C-e") #'joe/scroll-up-line) -(evil-global-set-key 'normal (kbd "C-y") #'joe/scroll-down-line) -(evil-global-set-key 'normal (kbd "p") project-prefix-map) +;; (elpaca 'evil-snipe +;; (require 'evil-snipe) +;; (evil-snipe-mode +1)) + +(elpaca 'evil-commentary + (evil-commentary-mode t)) + +(elpaca 'evil-goggles + (evil-goggles-mode t) + (setq evil-goggles-duration 0.075) + (setq evil-goggles-pulse t) + (setq evil-goggles-async-duration 0.55)) #+end_src ** Buffers @@ -647,7 +722,7 @@ weren't working, until I randomly saw this in someone's init.el (global-set-key (kbd "C-x k") #'joe/kill-this-buffer-or-popup) (global-set-key (kbd "C-x M-k") #'kill-buffer) -(straight-use-package 'all-the-icons-ibuffer) +(elpaca 'all-the-icons-ibuffer) (add-hook 'ibuffer-mode-hook #'all-the-icons-ibuffer-mode) (global-set-key [remap list-buffers] 'ibuffer) (global-set-key (kbd "C-x B") 'ibuffer) @@ -691,7 +766,7 @@ The theme of `C-x 4` bindings is that they operate on other windows, so this fun (define-key ctl-x-4-map (kbd "-") #'joe/window-split-horizontal) (define-key ctl-x-4-map (kbd "t") #'rotate-window) -(straight-use-package 'ace-window) +(elpaca 'ace-window) (global-set-key (kbd "C-x o") #'ace-window) (global-set-key (kbd "C-x C-o") #'ace-swap-window) @@ -704,7 +779,7 @@ The theme of `C-x 4` bindings is that they operate on other windows, so this fun *** Popper #+begin_src emacs-lisp -(straight-use-package 'popper) +(elpaca 'popper (require 'popper) (setq popper-reference-buffers '("\\*compilation\\*" compilation-mode @@ -774,7 +849,7 @@ The theme of `C-x 4` bindings is that they operate on other windows, so this fun (setq popper-display-function #'joe/popper-display-func) -(popper-mode t) +(popper-mode t)) #+end_src *** Scrolling #+begin_src emacs-lisp :tangle no @@ -818,13 +893,13 @@ The theme of `C-x 4` bindings is that they operate on other windows, so this fun (global-set-key (kbd "C-S-v") #'joe/smooth-scroll-short-down) (global-set-key (kbd "M-S-v") #'joe/smooth-scroll-short-up) -(straight-use-package 'topspace) +(elpaca 'topspace) #+end_src ** Tabs/Workspaces *** Centaur Tabs #+begin_src emacs-lisp -(straight-use-package 'centaur-tabs) +(elpaca 'centaur-tabs (setq centaur-tabs-set-bar 'under) (setq x-underline-at-descent-line t) (setq centaur-tabs-set-close-button nil) @@ -835,10 +910,12 @@ The theme of `C-x 4` bindings is that they operate on other windows, so this fun (setq centaur-tabs-show-new-tab-button nil) (setq centaur-tabs-label-fixed-length 16) -(global-set-key (kbd "C-") #'centaur-tabs-forward-tab) -(global-set-key (kbd "C-S-") #'centaur-tabs-backward-tab) -(global-set-key (kbd "C-M-") #'centaur-tabs-forward-group) -(global-set-key (kbd "C-M-S-") #'centaur-tabs-backward-group) +(global-set-key (kbd "s-n") #'centaur-tabs-forward-tab) +(global-set-key (kbd "s-p") #'centaur-tabs-backward-tab) +(global-set-key (kbd "s-N") #'centaur-tabs-forward-group) +(global-set-key (kbd "s-P") #'centaur-tabs-backward-group) +(global-set-key (kbd "C-s-p") #'centaur-tabs-move-current-tab-to-left) +(global-set-key (kbd "C-s-n") #'centaur-tabs-move-current-tab-to-right) (dolist (mode '(dashboard-mode-hook)) (add-hook mode 'centaur-tabs-local-mode)) @@ -869,10 +946,10 @@ The theme of `C-x 4` bindings is that they operate on other windows, so this fun (t "Emacs"))))) -(centaur-tabs-mode +1) +(centaur-tabs-mode +1)) #+end_src *** Tabs -#+begin_src emacs-lisp +#+begin_src emacs-lisp :tangle no ;; (setq tab-bar-mode t) ;; (setq tab-bar-show nil) @@ -925,134 +1002,135 @@ The theme of `C-x 4` bindings is that they operate on other windows, so this fun Vertico Embark Marginalia Consult Orderless #+begin_src emacs-lisp -(straight-use-package 'all-the-icons-completion) -(straight-use-package '(vertico :files (:defaults "extensions/*") - :includes (vertico-indexed - vertico-repeat - vertico-directory))) + (elpaca 'all-the-icons-completion) + (elpaca '(vertico :files (:defaults "extensions/*") + :includes (vertico-indexed + vertico-repeat + vertico-directory)) -(vertico-mode) -;; (straight-use-package 'vertico-posframe) + (vertico-mode) + ;; (elpaca 'vertico-posframe) -(define-key vertico-map (kbd "C-w") #'vertico-directory-delete-word) -;; (define-key vertico-map (kbd "C-r") #'vertico-repeat-) + (define-key vertico-map (kbd "C-w") #'vertico-directory-delete-word) + ;; (define-key vertico-map (kbd "C-r") #'vertico-repeat-) -;; (vertico-posframe-mode t) -(vertico-indexed-mode) -;; (setq vertico-posframe-parameters -;; '((left-fringe . 100) -;; (right-fringe . 100))) + ;; (vertico-posframe-mode t) + (vertico-indexed-mode) + ;; (setq vertico-posframe-parameters + ;; '((left-fringe . 100) + ;; (right-fringe . 100))) -;; (setq vertico-posframe-border-width 5) -;; (setq vertico-posframe-min-height 20) -;; (defun posframe-poshandler-slightly-below-top (info) -;; (cons (/ (- (plist-get info :parent-frame-width) -;; (plist-get info :posframe-width)) -;; 2) -;; 150)) -;; (setq vertico-posframe-poshandler #'posframe-poshandler-slightly-below-top) + ;; (setq vertico-posframe-border-width 5) + ;; (setq vertico-posframe-min-height 20) + ;; (defun posframe-poshandler-slightly-below-top (info) + ;; (cons (/ (- (plist-get info :parent-frame-width) + ;; (plist-get info :posframe-width)) + ;; 2) + ;; 150)) + ;; (setq vertico-posframe-poshandler #'posframe-poshandler-slightly-below-top) -(setq vertico-count 17 - vertico-resize nil - vertico-cycle t) + (setq vertico-count 17 + vertico-resize nil + vertico-cycle t) -(define-key vertico-map (kbd "C-M-n") #'vertico-next-group) -;; #' "C-M-p" #'vertico-previous-group) + (require 'savehist) + (savehist-mode) + (add-hook 'minibuffer-setup-hook #'vertico-repeat-save) + (add-to-list 'savehist-additional-variables 'vertico-repeat-history) -(require 'savehist) -(savehist-mode) -(add-hook 'minibuffer-setup-hook #'vertico-repeat-save) -(add-to-list 'savehist-additional-variables 'vertico-repeat-history) + (define-key vertico-map (kbd "C-M-n") #'vertico-next-group)) + ;; #' "C-M-p" #'vertico-previous-group) -(straight-use-package 'vertico-directory) -;; :bind (:map vertico-map -;; ("RET" . vertico-directory-enter) -;; ("DEL" . vertico-directory-delete-char) -;; ("M-DEL" . vertico-directory-delete-word)) -;; :hook (rfn-eshadow-update-overlay . vertico-directory-tidy)) -(straight-use-package 'embark) +;; (elpaca 'vertico-directory) + ;; :bind (:map vertico-map + ;; ("RET" . vertico-directory-enter) + ;; ("DEL" . vertico-directory-delete-char) + ;; ("M-DEL" . vertico-directory-delete-word)) + ;; :hook (rfn-eshadow-update-overlay . vertico-directory-tidy)) -(setq embark-quit-after-action '((kill-buffer . nil))) + (elpaca 'embark -(defvar joe-mode-map - (let ((map (make-sparse-keymap))) - ;; (define-key map (kbd "C-'") #'embark-act) - (define-key map (kbd "M-'") #'embark-dwim) - (define-key map (kbd "C-/") #'comment-line) - map) - "my-keys-minor-mode keymap.") + (setq embark-quit-after-action '((kill-buffer . nil))) -(define-minor-mode joe-mode - "A minor mode so that my key settings override annoying major modes." - :init-value t - :lighter " joe-keys") + (defvar joe-mode-map + (let ((map (make-sparse-keymap))) + ;; (define-key map (kbd "C-'") #'embark-act) + (define-key map (kbd "M-'") #'embark-dwim) + (define-key map (kbd "C-/") #'comment-line) + map) + "my-keys-minor-mode keymap.") -(joe-mode t) + (define-minor-mode joe-mode + "A minor mode so that my key settings override annoying major modes." + :init-value t + :lighter " joe-keys") -(defun embark-which-key-indicator () - "An embark indicator that displays keymaps using which-key. -The which-key help message will show the type and value of the -current target followed by an ellipsis if there are further -targets." - (lambda (&optional keymap targets prefix) - (if (null keymap) - (which-key--hide-popup-ignore-command) - (which-key--show-keymap - (if (eq (plist-get (car targets) :type) 'embark-become) - "Become" - (format "Act on %s '%s'%s" - (plist-get (car targets) :type) - (embark--truncate-target (plist-get (car targets) :target)) - (if (cdr targets) "…" ""))) - (if prefix - (pcase (lookup-key keymap prefix 'accept-default) - ((and (pred keymapp) km) km) - (_ (key-binding prefix 'accept-default))) - keymap) - nil nil t (lambda (binding) - (not (string-suffix-p "-argument" (cdr binding)))))))) + (joe-mode t) -(setq embark-indicators - '(embark-which-key-indicator - embark-highlight-indicator - embark-isearch-highlight-indicator)) + (defun embark-which-key-indicator () + "An embark indicator that displays keymaps using which-key. + The which-key help message will show the type and value of the + current target followed by an ellipsis if there are further + targets." + (lambda (&optional keymap targets prefix) + (if (null keymap) + (which-key--hide-popup-ignore-command) + (which-key--show-keymap + (if (eq (plist-get (car targets) :type) 'embark-become) + "Become" + (format "Act on %s '%s'%s" + (plist-get (car targets) :type) + (embark--truncate-target (plist-get (car targets) :target)) + (if (cdr targets) "…" ""))) + (if prefix + (pcase (lookup-key keymap prefix 'accept-default) + ((and (pred keymapp) km) km) + (_ (key-binding prefix 'accept-default))) + keymap) + nil nil t (lambda (binding) + (not (string-suffix-p "-argument" (cdr binding)))))))) -(defun embark-hide-which-key-indicator (fn &rest args) - "Hide the which-key indicator immediately when using the completing-read prompter." - (which-key--hide-popup-ignore-command) - (let ((embark-indicators - (remq #'embark-which-key-indicator embark-indicators))) - (apply fn args))) + (setq embark-indicators + '(embark-which-key-indicator + embark-highlight-indicator + embark-isearch-highlight-indicator)) -(advice-add #'embark-completing-read-prompter - :around #'embark-hide-which-key-indicator) + (defun embark-hide-which-key-indicator (fn &rest args) + "Hide the which-key indicator immediately when using the completing-read prompter." + (which-key--hide-popup-ignore-command) + (let ((embark-indicators + (remq #'embark-which-key-indicator embark-indicators))) + (apply fn args))) -(global-set-key (kbd "C-'") #'embark-act) + (advice-add #'embark-completing-read-prompter + :around #'embark-hide-which-key-indicator) -(straight-use-package 'embark-consult) + (global-set-key (kbd "C-'") #'embark-act)) -(straight-use-package 'marginalia) -(setq marginalia-annotators '(marginalia-annotators-heavy marginalia-annotators-light nil)) -(setq marginalia-align 'right) -(setq marginalia-max-relative-age most-positive-fixnum) -(marginalia-mode) -(define-key minibuffer-local-map (kbd "M-A") #'marginalia-cycle) -(require 'all-the-icons-completion) -(all-the-icons-completion-mode) -(all-the-icons-completion-marginalia-setup) + (elpaca 'embark-consult) -(add-hook 'marginalia-mode-hook #'all-the-icons-completion-marginalia-setup) + (elpaca 'marginalia + (setq marginalia-annotators '(marginalia-annotators-heavy marginalia-annotators-light nil)) + (setq marginalia-align 'right) + (setq marginalia-max-relative-age most-positive-fixnum) + (marginalia-mode) + (define-key minibuffer-local-map (kbd "M-A") #'marginalia-cycle) + (require 'all-the-icons-completion) + (all-the-icons-completion-mode) + (all-the-icons-completion-marginalia-setup) -(straight-use-package 'orderless) -(setq completion-styles '(orderless basic) - completion-category-overrides '((file (styles basic partial-completion)))) + (add-hook 'marginalia-mode-hook #'all-the-icons-completion-marginalia-setup)) + + (elpaca 'orderless + (setq completion-styles '(orderless basic) + completion-category-overrides '((file (styles basic partial-completion))))) #+end_src *** Consult #+begin_src emacs-lisp -(straight-use-package 'consult) -(straight-use-package 'consult-lsp) +(elpaca 'consult) +(elpaca 'consult-lsp) ;; (defun joe/consult-line () ;; (interactive) @@ -1071,13 +1149,15 @@ targets." #+end_src ** Dirvish/Dired #+begin_src emacs-lisp -(straight-use-package 'dirvish) +(elpaca 'dirvish) (with-eval-after-load 'dirvish (dirvish-override-dired-mode) (setq delete-by-moving-to-trash t) (setq dired-dwim-target t) (setq dirvish-reuse-session nil) + (add-hook 'dired-mode-hook 'centaur-tabs-local-mode) + (dirvish-define-preview exa (file) "Use `exa' to generate directory preview." :require ("exa") ; tell Dirvish to check if we have the executable @@ -1128,7 +1208,8 @@ targets." (kbd "M-j") #'dirvish-fd-jump))) (when (boundp 'evil-mode) - (evil-global-set-key 'normal (kbd "-") #'dirvish-dwim)) + (evil-define-key 'normal joe/evil-space-mode-map (kbd "_") #'project-dired) + (evil-define-key 'normal joe/evil-space-mode-map (kbd "-") #'dirvish-dwim)) (global-set-key (kbd "C-x d") #'dirvish-dwim) (global-set-key (kbd "C-x C-d") #'joe/dirvish-find-directory) @@ -1156,102 +1237,103 @@ targets." (define-key global-map (kbd "M-g e") 'avy-goto-word-0) ;; lots of candidates (define-key global-map (kbd "M-g g") 'avy-goto-line) ;; digits behave like goto-line (define-key global-map (kbd "M-g w") 'avy-goto-word-1) ;; first character of the word -(define-key global-map (kbd "M-g P") 'avy-pop-mark) +(define-key global-map (kbd "M-g P") 'avy-pop-mark)) #+end_src ** Helpful #+begin_src emacs-lisp -(straight-use-package 'helpful) +(elpaca 'helpful (global-set-key (kbd "C-h f") #'helpful-callable) (global-set-key (kbd "C-h v") #'helpful-variable) (global-set-key (kbd "C-h k") #'helpful-key) (global-set-key (kbd "C-h C-d") #'helpful-at-point) (global-set-key (kbd "C-h F") #'helpful-function) -(global-set-key (kbd "C-h C") #'helpful-command) +(global-set-key (kbd "C-h C") #'helpful-command)) #+end_src ** Terminals/Shells #+begin_src emacs-lisp -(straight-use-package 'vterm) +(elpaca 'vterm + (require 'vterm) + (setq vterm-shell "/bin/fish") + (setq vterm-timer-delay 0.01) + (setq vterm-buffer-name-string "VTerm - %s") + (setq vterm-max-scrollback 100000) + (setq vterm-kill-buffer-on-exit t) -(setq vterm-shell "/bin/fish") -(setq vterm-timer-delay 0.01) -(setq vterm-buffer-name-string "VTerm - %s") -(setq vterm-max-scrollback 100000) -(setq vterm-kill-buffer-on-exit t) + (defun joe/close-popup-buffer (vterm-buf event-msg) + (unless (or (eq popper-popup-status nil) + (eq popper-popup-status 'raised)) + (popper-close-latest))) -(defun joe/close-popup-buffer (vterm-buf event-msg) - (unless (or (eq popper-popup-status nil) - (eq popper-popup-status 'raised)) - (popper-close-latest))) + (setq vterm-exit-functions '(joe/close-popup-buffer)) -(setq vterm-exit-functions '(joe/close-popup-buffer)) + (defun joe/vterm-here () + (interactive) + (let ((vterm-buf (vterm--internal #'switch-to-buffer))) + (with-current-buffer vterm-buf + (setq popper-popup-status 'raised)))) -(defun joe/vterm-here () - (interactive) - (let ((vterm-buf (vterm--internal #'switch-to-buffer))) - (with-current-buffer vterm-buf - (setq popper-popup-status 'raised)))) + (global-set-key (kbd "C-c t") #'vterm) + (global-set-key (kbd "C-c T") #'joe/vterm-here) + ;; (setq explicit-shell-file-name "~/Development/fell/fell") + (add-hook 'shell-mode (lambda () (setq-local global-hl-line-mode nil))) + (setq shell-kill-buffer-on-exit t) -(global-set-key (kbd "C-c t") #'vterm) -(global-set-key (kbd "C-c T") #'joe/vterm-here) -;; (setq explicit-shell-file-name "~/Development/fell/fell") -(add-hook 'shell-mode (lambda () (setq-local global-hl-line-mode nil))) -(setq shell-kill-buffer-on-exit t) - -(add-hook 'vterm-mode-hook - (lambda () - (define-key vterm-mode-map (kbd "C-c C-x") #'vterm-send-C-x) - (when (boundp 'evil-mode) + (add-hook 'vterm-mode-hook + (lambda () + (define-key vterm-mode-map (kbd "C-c C-x") #'vterm-send-C-x) + (when (boundp 'evil-mode) (evil-define-key 'insert vterm-mode-map (kbd "C-w") #'vterm-send-C-w) (evil-define-key 'insert vterm-mode-map (kbd "") #'vterm-send-delete)) - (setq-local global-hl-line-mode nil))) + (setq-local global-hl-line-mode nil)))) #+end_src VTerm is loading TRAMP along with it which slows down init time noticeably so call this after startup. Reason we have to call this is so the vterm fucntion can call `vterm--internal`. -#+begin_src emacs-lisp -(add-hook 'emacs-startup-hook (lambda () (require 'vterm))) +#+begin_src emacs-lisp :tangle no +;; (add-hook 'emacs-startup-hook (lambda () (require 'vterm))) #+end_src ** Undo Fu #+begin_src emacs-lisp -(straight-use-package 'undo-fu) -(straight-use-package 'undo-fu-session) -(straight-use-package 'vundo) -(undo-fu-session-global-mode +1) + (elpaca 'undo-fu + (undo-fu-session-global-mode +1) + (setq undo-limit 6710886400) ;; 64mb. + (setq undo-strong-limit 100663296) ;; 96mb. + (setq undo-outer-limit 1006632960)) ;; 960mb. -(setq undo-fu-session-incompatible-files '("/COMMIT_EDITMSG\\'" "/git-rebase-todo\\'")) + (elpaca 'undo-fu-session + (setq undo-fu-session-incompatible-files '("/COMMIT_EDITMSG\\'" "/git-rebase-todo\\'")) -(setq undo-limit 6710886400) ;; 64mb. -(setq undo-strong-limit 100663296) ;; 96mb. -(setq undo-outer-limit 1006632960) ;; 960mb. + ) + (elpaca 'vundo) #+end_src ** Which Key #+begin_src emacs-lisp -(straight-use-package 'which-key) -(setq which-key-idle-delay 0.3) -(add-hook 'after-init-hook (lambda () (which-key-mode))) - -(when (boundp 'evil-mode) - (which-key-add-keymap-based-replacements evil-normal-state-map - "f" '("Files") - "b" '("Buffers") - "B" '("Bookmarks") - "c" '("Consult") - "d" '("Dired") - "g" '("Git") - "m" '("Make") - "t" '("Tabs") - "p" '("Packages") - "s" '("Shell (vterm)") - "h" '("Help"))) - +(elpaca 'which-key + (setq which-key-idle-delay 0.3) + (which-key-mode) + (when (boundp 'evil-mode) + (which-key-add-keymap-based-replacements evil-normal-state-map + "SPC f" '("Files") + "SPC b" '("Buffers") + "SPC B" '("Bookmarks") + "SPC c" '("Consult") + "SPC d" '("Dired") + "SPC g" '("Git") + "SPC m" '("Make") + "SPC t" '("Tabs") + "SPC p" '("Packages") + "SPC s" '("Shell (vterm)") + "SPC h" '("Help")))) #+end_src ** IDE Features *** REPLs #+begin_src emacs-lisp -(evil-define-key 'insert comint-mode-map (kbd "C-n") 'comint-next-input) -(evil-define-key 'insert comint-mode-map (kbd "C-p") 'comint-previous-input) + +(when (boundp 'evil-mode) + (evil-define-key 'insert comint-mode-map (kbd "C-n") 'comint-next-input) + (evil-define-key 'insert comint-mode-map (kbd "C-p") 'comint-previous-input)) #+end_src *** Company #+begin_src rust @@ -1260,26 +1342,6 @@ println!("Hello world"); #+begin_src emacs-lisp -;; (global-set-key [remap dabbrev-expand] 'hippie-expand) -;; (global-set-key [remap hippie-expand] 'dabbrev-expand) -;; (global-set-key (kbd "M-/") 'dabbrev-expand) - -;; (straight-use-package 'fancy-dabbrev) -;; (global-set-key (kbd "TAB") 'fancy-dabbrev-expand-or-indent) -;; (global-set-key (kbd "") 'fancy-dabbrev-backward) - -;; (global-set-key (kbd "TAB") 'indent-for-tab-command) -;; (global-set-key (kbd "") nil) - -;; (straight-use-package 'kind-icon) -;; (require 'kind-icon) -;; (setq completion-in-region-function #'consult-completion-in-region) -;; (setq completion-in-region-function (kind-icon-enhance-completion completion-in-region-function)) -;; (setq completion-in-region-function -;; (kind-icon-enhance-completion -;; (lambda (&rest args) -;; (let ((marginalia-classifiers nil)) -;; (apply #'consult-completion-in-region args))))) (setq completion-in-region-function (lambda (&rest args) @@ -1288,14 +1350,14 @@ println!("Hello world"); #'completion--in-region) args))) -(straight-use-package 'company) +(elpaca 'company) + +(with-eval-after-load 'company +(add-to-list 'completion-at-point-functions #'elisp-completion-at-point) (require 'company) (setq company-minimum-prefix-length 1) (setq company-tooltip-align-annotations t) (setq company-minimum-prefix-length 2) - -(add-to-list 'completion-at-point-functions #'elisp-completion-at-point) -(with-eval-after-load 'company (define-key company-active-map (kbd "C-n") nil) (define-key company-active-map (kbd "C-p") nil) (define-key company-active-map (kbd "") nil) @@ -1313,121 +1375,68 @@ println!("Hello world"); ;; '(company-pseudo-tooltip-unless-just-one-frontend ;; company-echo-metadata-frontend) company-backends '((company-capf company-elisp company-files))) - (setq company-transformers '(company-sort-by-occurrence))) -(add-hook 'after-init-hook (lambda () (global-company-mode))) -;; (setq completion-in-region-function #'completion--in-region) -;; (setq completion-in-region-function -;; (lambda (&rest args) -;; (apply (if vertico-mode -;; #'consult-completion-in-region -;; #'completion--in-region) -;; args))) - -;; (straight-use-package 'company) -;; (require 'company) -;; (setq company-minimum-prefix-length 1) -;; (setq company-tooltip-align-annotations t) -;; (setq company-minimum-prefix-length 2) - -;; (with-eval-after-load 'company -;; (define-key company-active-map (kbd "C-n") nil) -;; (define-key company-active-map (kbd "C-p") nil) -;; (define-key company-active-map (kbd "") nil) -;; (define-key company-active-map (kbd "RET") nil) -;; (define-key company-active-map (kbd "M-d") #'company-show-doc-buffer) -;; (define-key company-active-map (kbd "C-f") #'company-complete-selection) -;; (define-key company-active-map [tab] #'company-complete-common-or-cycle) -;; (define-key company-active-map (kbd "") (lambda () (interactive) (company-complete-common-or-cycle -1))) - -;; (setq company-idle-delay 0.15 -;; company-tooltip-idle-delay 20 -;; company-require-match nil -;; company-frontends '(company-preview-frontend company-echo-metadata-frontend) -;; ;; company-frontends -;; ;; '(company-pseudo-tooltip-unless-just-one-frontend -;; ;; company-echo-metadata-frontend) -;; company-backends '((company-capf company-elisp company-files))) -;; (setq company-transformers '(company-sort-by-occurrence))) -;; (add-hook 'after-init-hook (lambda () (global-company-mode))) - -;; (dolist (mode '(inferior-python-mode-hook)) -;; (add-hook mode (lambda () (company-mode -1)))) - -;; (straight-use-package 'cape) -;; ;; (setq completion-at-point-functions '(cape-symbol)) -;; (add-to-list 'completion-at-point-functions #'cape-dabbrev) -;; (add-to-list 'completion-at-point-functions #'cape-file) -;; (add-to-list 'completion-at-point-functions #'cape-symbol) -;; (setq completion-at-point-functions '(cape-symbol)) - -;; (straight-use-package 'corfu) -;; (global-corfu-mode 1) -;; (setq corfu-auto t) -;; (setq corfu-auto-delay 0.15) -;; (setq corfu-count 2) - -;; ;; (setq corfu-preview-current t) -;; (define-key corfu-map "\C-f" #'corfu-complete) - + (setq company-transformers '(company-sort-by-occurrence)) + (global-company-mode)) #+end_src *** LSP #+begin_src emacs-lisp -(straight-use-package 'lsp-mode) -(straight-use-package 'lsp-ui) -(setq lsp-enable-which-key-integration t) -(setq lsp-keymap-prefix "C-c c") +(elpaca 'lsp-mode + (setq lsp-enable-which-key-integration t) + (setq lsp-keymap-prefix "C-c c") -;; (setq lsp-ui-peek-always-show t) -;; (setq lsp-ui-doc-enable t) -;; TODO: Disable lsp sideline -(setq lsp-headerline-breadcrumb-enable nil) -(setq lsp-eldoc-enable-hover t) -(setq max-mini-window-height 0.25) -(setq lsp-eldoc-enable-hover t) -(setq lsp-ui-doc-enable nil) -(setq eldoc-echo-area-use-multiline-p 'truncate-sym-name-if-fit) -(setq eldoc-idle-delay 0) -(setq lsp-idle-delay 0.2) + ;; (setq lsp-ui-peek-always-show t) + ;; (setq lsp-ui-doc-enable t) + ;; TODO: Disable lsp sideline + (setq lsp-headerline-breadcrumb-enable nil) + (setq lsp-eldoc-enable-hover t) + (setq max-mini-window-height 0.25) + (setq lsp-eldoc-enable-hover t) + (setq lsp-ui-doc-enable nil) + (setq eldoc-echo-area-use-multiline-p 'truncate-sym-name-if-fit) + (setq eldoc-idle-delay 0) + (setq lsp-idle-delay 0.2) -;; Signatures -(setq lsp-signature-doc-lines t) -(setq lsp-signature-render-documentation nil) -(setq lsp-eldoc-render-all nil) + ;; Signatures + (setq lsp-signature-doc-lines t) + (setq lsp-signature-render-documentation nil) + (setq lsp-eldoc-render-all nil) -(when (boundp 'evil-mode) -(evil-global-set-key 'normal (kbd "M-d") #'lsp-describe-thing-at-point) -(evil-global-set-key 'normal (kbd "lh") 'lsp-headerline-breadcrumb-mode) -(evil-global-set-key 'normal (kbd "li") 'lsp-rust-analyzer-inlay-hints-mode) -(evil-global-set-key 'normal (kbd "cs") 'consult-lsp-symbols) -(evil-global-set-key 'normal (kbd "cf") 'consult-lsp-file-symbols)) + (when (boundp 'evil-mode) + (evil-global-set-key 'normal (kbd "M-d") #'lsp-describe-thing-at-point) + (evil-global-set-key 'normal (kbd "lh") 'lsp-headerline-breadcrumb-mode) + (evil-global-set-key 'normal (kbd "li") 'lsp-rust-analyzer-inlay-hints-mode) + (evil-global-set-key 'normal (kbd "cs") 'consult-lsp-symbols) + (evil-global-set-key 'normal (kbd "cf") 'consult-lsp-file-symbols)) -;; This function allows us to extract Rust's true function signature -(cl-defmethod lsp-clients-extract-signature-on-hover (contents (_server-id (eql rust-analyzer))) - (-let* (((&hash "value") contents) - (groups (--partition-by (s-blank? it) (s-lines (s-trim value)))) - (sig_group (if (s-equals? "```rust" (car (-third-item groups))) - (-third-item groups) - (car groups))) - (sig (--> sig_group - (--drop-while (s-equals? "```rust" it) it) - (--take-while (not (s-equals? "```" it)) it) - (--map (s-trim it) it) - (s-join " " it)))) - (lsp--render-element (concat "```rust\n" sig "\n```")))) + ;; This function allows us to extract Rust's true function signature + (cl-defmethod lsp-clients-extract-signature-on-hover (contents (_server-id (eql rust-analyzer))) + (-let* (((&hash "value") contents) + (groups (--partition-by (s-blank? it) (s-lines (s-trim value)))) + (sig_group (if (s-equals? "```rust" (car (-third-item groups))) + (-third-item groups) + (car groups))) + (sig (--> sig_group + (--drop-while (s-equals? "```rust" it) it) + (--take-while (not (s-equals? "```" it)) it) + (--map (s-trim it) it) + (s-join " " it)))) + (lsp--render-element (concat "```rust\n" sig "\n```"))))) + +(elpaca 'lsp-ui) #+end_src *** Flycheck #+begin_src emacs-lisp -(straight-use-package 'flycheck) +(elpaca 'flycheck) ;; TODO Add wrapping to these functions (when (boundp 'evil-mode) -(evil-global-set-key 'normal (kbd "M-e") #'flycheck-next-error) -(evil-global-set-key 'normal (kbd "M-E") #'flycheck-previous-error) -(evil-global-set-key 'normal (kbd "ee") 'flycheck-mode) -(evil-global-set-key 'normal (kbd "el") #'flycheck-list-errors) -(evil-global-set-key 'normal (kbd "ce") #'consult-lsp-diagnostics)) + (evil-global-set-key 'normal (kbd "M-e") #'flycheck-next-error) + (evil-global-set-key 'normal (kbd "M-E") #'flycheck-previous-error) + (evil-global-set-key 'normal (kbd "ee") 'flycheck-mode) + (evil-global-set-key 'normal (kbd "el") #'flycheck-list-errors) + (evil-global-set-key 'normal (kbd "ce") #'consult-lsp-diagnostics))) #+end_src *** Compilation #+begin_src emacs-lisp @@ -1479,7 +1488,7 @@ println!("Hello world"); ** Debugging *** DAP #+begin_src emacs-lisp -(straight-use-package 'dap-mode) +(elpaca 'dap-mode (require 'dap-mode) ;; (setq dap-auto-configure-features '(locals breakpoints expressions tooltip)) @@ -1504,25 +1513,25 @@ println!("Hello world"); :cwd "${workspaceFolder}" :console "external" :dap-compilation "cargo build" - :dap-compilation-dir "${workspaceFolder}")) + :dap-compilation-dir "${workspaceFolder}"))) #+end_src ** Languages *** Python #+begin_src emacs-lisp -(straight-use-package 'elpy) +(elpaca 'elpy) (define-key inferior-python-mode-map (kbd "C-n") #'comint-next-input) (define-key inferior-python-mode-map (kbd "C-p") #'comint-previous-input) #+end_src> *** Rust #+begin_src emacs-lisp -(straight-use-package 'rustic) -(straight-use-package 'ob-rust) +(elpaca 'rustic) +(elpaca 'ob-rust) ;; Org-Babel ;; Disabling until we figure out how to get it working -;; (straight-use-package 'parsec) ;; Required by evcxr-mode +;; (elpaca 'parsec) ;; Required by evcxr-mode -;; (straight-use-package +;; (elpaca ;; '(evcxr ;; :type git ;; :host github @@ -1555,7 +1564,7 @@ println!("Hello world"); #+end_src *** Web #+begin_src emacs-lisp -(straight-use-package 'typescript-mode) +(elpaca 'typescript-mode) (setq typescript-indent-level 2) #+end_src *** C @@ -1566,7 +1575,7 @@ whether the point hasn't been moved. This way, if I switched to another popper b it doesn't close it. #+begin_src emacs-lisp -(straight-use-package 'disaster) +(elpaca 'disaster) (defun joe/c-mode-hook () (local-set-key (kbd "C-x c r") (defun joe/make-run () (interactive) (compile "make run"))) (local-set-key (kbd "C-x c c") (defun joe/make () (interactive) (compile "make"))) @@ -1576,27 +1585,29 @@ it doesn't close it. #+end_src *** Haskell #+begin_src emacs-lisp -(straight-use-package 'haskell-mode) -(setq haskell-interactive-popup-errors nil) -(evil-define-key 'insert haskell-interactive-mode-map (kbd "C-n") #'haskell-interactive-mode-history-next) -(evil-define-key 'insert haskell-interactive-mode-map (kbd "C-p") #'haskell-interactive-mode-history-previous) + (elpaca 'haskell-mode) + (setq haskell-interactive-popup-errors nil) + (when (boundp 'evil-mode) + + (evil-define-key 'insert haskell-interactive-mode-map (kbd "C-n") #'haskell-interactive-mode-history-next) + (evil-define-key 'insert haskell-interactive-mode-map (kbd "C-p") #'haskell-interactive-mode-history-previous)) #+end_src *** Clojure #+begin_src emacs-lisp -(straight-use-package 'clojure-mode) -(straight-use-package 'cider) +(elpaca 'clojure-mode) +(elpaca 'cider) (setq cider-show-error-buffer 'only-in-repl) #+end_src *** OCaml #+begin_src emacs-lisp :tangle no -(straight-use-package 'tuareg) -(straight-use-package 'dune) -(straight-use-package 'utop) -(straight-use-package 'merlin) -(straight-use-package 'merlin-eldoc) +(elpaca 'tuareg) +(elpaca 'dune) +(elpaca 'utop) +(elpaca 'merlin) +(elpaca 'merlin-eldoc) ;; Might be worth checking out, depeding on whether we stick with flycheck or not -;; (straight-use-package 'flycheck-ocaml) +;; (elpaca 'flycheck-ocaml) ;; Also check this out, see if it adds anything ;; (require 'ocp-indent) @@ -1635,72 +1646,72 @@ and there's no need for a middle-man when it's already been implemented. #+end_src *** FSharp #+begin_src emacs-lisp -(straight-use-package 'fsharp-mode) -;; (straight-use-package 'eglot-fsharp) +(elpaca 'fsharp-mode) +;; (elpaca 'eglot-fsharp) #+end_src *** Go #+begin_src emacs-lisp -(straight-use-package 'go-mode) -;; (straight-use-package 'go-imports) +(elpaca 'go-mode) +;; (elpaca 'go-imports) #+end_src *** Other #+begin_src emacs-lisp -(straight-use-package 'json) -(straight-use-package 'markdown-mode) +(elpaca 'json-mode) +(elpaca 'markdown-mode) #+end_src ** Org Mode #+begin_src emacs-lisp -(straight-use-package 'org-bullets) + (elpaca 'org-bullets) -(defun joe/org-init () - (setq org-todo-keywords '((sequence "TODO" "IN-PROGRESS" "|" "DONE" "BACKLOG"))) - (setq org-agenda-files '("~/todo.org")) + (defun joe/org-init () + (setq org-todo-keywords '((sequence "TODO" "IN-PROGRESS" "|" "DONE" "BACKLOG"))) + (setq org-agenda-files '("~/todo.org")) - (org-babel-do-load-languages - 'org-babel-load-languages - '((emacs-lisp . t) - (makefile . t) - (ocaml . t) - (python . t) - (C . t) - (haskell . t) - (rust . t) - (shell . t))) + (org-babel-do-load-languages + 'org-babel-load-languages + '((emacs-lisp . t) + (makefile . t) + (ocaml . t) + (python . t) + (C . t) + (haskell . t) + ;; (rust . t) + (shell . t))) - (require 'org-tempo) - (add-to-list 'org-structure-template-alist '("el" . "src emacs-lisp")) - (add-to-list 'org-structure-template-alist '("ml" . "src ocaml")) - (add-to-list 'org-structure-template-alist '("rs" . "src rust")) - (add-to-list 'org-structure-template-alist '("py" . "src python")) - (add-to-list 'org-structure-template-alist '("hs" . "src haskell")) - (add-to-list 'org-structure-template-alist '("cc" . "src C :includes stdio.h stdlib.h")) - (setq org-edit-src-content-indentation 0)) -(with-eval-after-load 'org (joe/org-init)) + (require 'org-tempo) + (add-to-list 'org-structure-template-alist '("el" . "src emacs-lisp")) + (add-to-list 'org-structure-template-alist '("ml" . "src ocaml")) + (add-to-list 'org-structure-template-alist '("rs" . "src rust")) + (add-to-list 'org-structure-template-alist '("py" . "src python")) + (add-to-list 'org-structure-template-alist '("hs" . "src haskell")) + (add-to-list 'org-structure-template-alist '("cc" . "src C :includes stdio.h stdlib.h")) + (setq org-edit-src-content-indentation 0)) + (with-eval-after-load 'org (joe/org-init)) -(setq org-blank-before-new-entry - '((heading . nil) - (plain-list-item . nil))) -(setq org-cycle-separator-lines 1) -(setq org-hide-emphasis-markers t) -(setq org-src-window-setup 'current-window) + (setq org-blank-before-new-entry + '((heading . nil) + (plain-list-item . nil))) + (setq org-cycle-separator-lines 1) + (setq org-hide-emphasis-markers t) + (setq org-src-window-setup 'current-window) -(defun joe/org-hook () - (local-set-key (kbd "C-. C-i") 'consult-org-heading) - (org-bullets-mode) - (org-indent-mode)) -(add-hook 'org-mode-hook 'joe/org-hook) + (defun joe/org-hook () + (local-set-key (kbd "C-. C-i") 'consult-org-heading) + (org-bullets-mode) + (org-indent-mode)) + (add-hook 'org-mode-hook 'joe/org-hook) -(straight-use-package 'org-kanban) + (elpaca 'org-kanban) #+end_src ** Magit The best git porcelain/client I've ever used. Also kill stray magit buffers left over as explained [[https://manueluberti.eu/emacs/2018/02/17/magit-bury-buffer/][here]] #+begin_src emacs-lisp -(straight-use-package 'magit) +(elpaca 'magit) (defun joe/magit-kill-buffers (param) "Restore window configuration and kill all Magit buffers." @@ -1721,7 +1732,14 @@ The best git porcelain/client I've ever used. Also kill stray magit buffers left ** Restclient #+begin_src emacs-lisp -(straight-use-package 'restclient) +(elpaca 'restclient) + +(add-to-list 'auto-mode-alist '("\\.restclient\\'" . restclient-mode)) + +(with-eval-after-load 'restclient + (define-key restclient-mode-map (kbd "C-c C-c") #'restclient-http-send-current-stay-in-window) + (define-key restclient-mode-map (kbd "C-c C-v") #'restclient-http-send-current)) + #+end_src