Emacs : straight

This commit is contained in:
2023-01-17 03:54:36 +09:00
parent adaa9bdd78
commit d3dd62be34

View File

@ -46,27 +46,45 @@ Emacs Configuration for emacs 29.50
#+end_src #+end_src
*** Package Function *** Package Function
#+begin_src emacs-lisp :tangle ~/.config/emacs/init.el #+begin_src emacs-lisp :tangle ~/.config/emacs/init.el
(require 'package) (defvar bootstrap-version)
(add-to-list 'package-archives '("stable" . "https://stable.melpa.org/packages/")) (defvar comp-deferred-compilation-deny-list ()) ; workaround, otherwise straight shits itself
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/")) (let ((bootstrap-file
(customize-set-variable 'package-archive-priorities (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
'(("gnu" . 99) ; prefer GNU packages (bootstrap-version 5))
("nongnu" . 80) ; use non-gnu packages if (unless (file-exists-p bootstrap-file)
; not found in GNU elpa (with-current-buffer
("stable" . 70) ; prefer "released" versions (url-retrieve-synchronously
; from melpa "https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
("melpa" . 0))) ; if all else fails, get it 'silent 'inhibit-cookies)
; from melpa (goto-char (point-max))
(eval-print-last-sexp)))
(load bootstrap-file nil 'nomessage))
(package-initialize)
(unless package-archive-contents
(package-refresh-contents))
(straight-use-package '(use-package :build t))
(setq use-package-always-ensure t)
;;(require 'package)
;;(add-to-list 'package-archives '("stable" . "https://stable.melpa.org/packages/"))
;;(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/"))
;;(customize-set-variable 'package-archive-priorities
;; '(("gnu" . 99) ; prefer GNU packages
;; ("nongnu" . 80) ; use non-gnu packages if
;; ; not found in GNU elpa
;; ("stable" . 70) ; prefer "released" versions
;; ; from melpa
;; ("melpa" . 0))) ; if all else fails, get it
;; ; from melpa
;; make sure the elpa/ folder exists after setting it above. ;; make sure the elpa/ folder exists after setting it above.
;;(defmacro usr-package-install (package)
;; `(unless (package-installed-p ,package) (package-install ,package)))
;;(package-initialize)
;;(if (version< emacs-version "29")
;; (usr-package-install 'use-package)) ;; <emacs29
(unless (file-exists-p package-user-dir) (unless (file-exists-p package-user-dir)
(mkdir package-user-dir t)) (mkdir package-user-dir t))
(defmacro usr-package-install (package)
`(unless (package-installed-p ,package) (package-install ,package)))
(package-initialize)
(if (version< emacs-version "29")
(usr-package-install 'use-package)) ;; <emacs29
;;; init.el ends here ;;; init.el ends here
#+end_src #+end_src
*** Add other modules *** Add other modules
@ -150,6 +168,10 @@ Emacs Configuration for emacs 29.50
(setq default-input-method "korean-hangul") (setq default-input-method "korean-hangul")
;; when programming _
(modify-syntax-entry ?_ "w")
(setq visible-bell t)
(add-hook 'emacs-startup-hook (add-hook 'emacs-startup-hook
(lambda () (lambda ()
(custom-set-faces (custom-set-faces
@ -162,12 +184,12 @@ Emacs Configuration for emacs 29.50
(require 'custom-keybindings) (require 'custom-keybindings)
(require 'custom-default) (require 'custom-default)
(require 'custom-completion) (require 'custom-completion)
(require 'custom-projects) ;;(require 'custom-projects)
(require 'custom-latex) ;;(require 'custom-latex)
(require 'custom-org) ;;(require 'custom-org)
;;(require 'custom-workspaces) ;;(require 'custom-workspaces)
(require 'custom-languages) ;;(require 'custom-languages)
(require 'custom-extra) ;;(require 'custom-extra)
;;; config.el ends here ;;; config.el ends here
#+end_src #+end_src
@ -240,55 +262,73 @@ emacs built-in package config
#+end_src #+end_src
**** Dired **** Dired
#+begin_src emacs-lisp :mkdirp yes :tangle ~/.config/emacs/modules/custom-default.el #+begin_src emacs-lisp :mkdirp yes :tangle ~/.config/emacs/modules/custom-default.el
(usr-package-install 'dired-single) (use-package dired
(usr-package-install 'diredfl) ;; colorful dired :ensure nil
(usr-package-install 'dired-git-info) :straight nil
(usr-package-install 'diff-hl) ;; diff highlight :commands (dired dired-jump)
(usr-package-install 'dired-rsync) :bind (("C-x C-j" . dired-jump))
(usr-package-install 'all-the-icons-dired) :custom ((dired-listing-switches "-agho --group-directories-first"))
(usr-package-install 'dired-hide-dotfiles) :config
(usr-package-install 'peep-dired)
;; dired default
(setq dired-listing-switches "-agho --group-directories-first")
(evil-collection-define-key 'normal 'dired-mode-map (evil-collection-define-key 'normal 'dired-mode-map
"h" 'dired-up-directory ;dired-single-up-directory "h" 'dired-up-directory ;dired-single-up-directory
"l" 'dired-find-file) ;dired-single-buffer) "l" 'dired-find-file)) ;dired-single-buffer)
;;(require 'dired-single) (use-package dired-single
;;(use-package dired-single :straight (:build t)
;; :commands (dired dired-jump)) :defer t
;; colorful :commands (dired dired-jump))
(add-hook 'dired-mode-hook #'diredfl-mode) (use-package diredfl ;; colorful dired
;; git info :straight (:build t)
:defer t
:hook dired-mode)
(use-package dired-git-info
:straight (:build t)
:defer t
:config
(evil-collection-define-key 'normal 'dired-mode-map (evil-collection-define-key 'normal 'dired-mode-map
")" 'dired-git-info-mode) ")" 'dired-git-info-mode))
;; diff highlight (use-package diff-hl
(add-hook 'dired-mode-hook #'diff-hl-dired-mode-unless-remote) :straight (:build t)
(add-hook 'magit-post-refresh-hook #'diff-hl-dired-mode-unless-remote) :defer t
(diff-hl-margin-mode) :hook ((dired-mode-hook . diff-hl-dired-mode-unless-remote)
;; rsync (magit-post-refresh-hook . diff-hl-magit-post-refresh))
(bind-key "C-c C-r" 'dired-rsync dired-mode-map) :config
;; all-the icons (diff-hl-margin-mode))
(add-hook 'dired-mode-hook #'all-the-icons-dired-mode) (use-package dired-rsync
:straight (:build t)
:defer t
:config
(bind-key "C-c C-r" 'dired-rsync dired-mode-map))
(use-package all-the-icons-dired
:straight (:build t)
:defer t
:hook dired-mode)
(use-package dired-hide-dotfiles
:straight (:build t)
:defer t
:hook (dired-mode)
:config
(evil-collection-define-key 'normal 'dired-mode-map
"H" 'dired-hide-dotfiles-mode))
;;(usr-package-install 'peep-dired)
;; HACK:Fixes #1929: icons break file renaming in Emacs 27+, because the icon ;; HACK:Fixes #1929: icons break file renaming in Emacs 27+, because the icon
;; is considered part of the filename, so we disable icons while we're in ;; is considered part of the filename, so we disable icons while we're in
;; wdired-mode. ;; wdired-mode.
;;(when EMACS27+ ;;(when EMACS27+
(defvar +wdired-icons-enabled -1) (defvar +wdired-icons-enabled -1)
;; hide dotfiles
(add-hook 'dired-mode-hook #'dired-hide-dotfiles-mode)
(evil-collection-define-key 'normal 'dired-mode-map
"H" 'dired-hide-dotfiles-mode)
;; TODO: check emacs29 updates ;; TODO: check emacs29 updates
;;(csetq dired-mouse-drag-files t ;;(csetq dired-mouse-drag-files t
;; mouse-drag-and-drop-region-cross-program t) ;; mouse-drag-and-drop-region-cross-program t)
; peep dired (use-package peep-dired
:straight (:build t)
:defer t
:hook (peep-dired-hook . evil-normalize-keymaps)
:config
(evil-define-key 'normal peep-dired-mode-map (evil-define-key 'normal peep-dired-mode-map
(kbd "j") 'peep-dired-next-file (kbd "j") 'peep-dired-next-file
(kbd "k") 'peep-dired-prev-file) (kbd "k") 'peep-dired-prev-file))
(add-hook 'peep-dired-hook 'evil-normalize-keymaps)
#+end_src #+end_src
**** Provide Modules **** Provide Modules
#+begin_src emacs-lisp :mkdirp yes :tangle ~/.config/emacs/modules/custom-default.el #+begin_src emacs-lisp :mkdirp yes :tangle ~/.config/emacs/modules/custom-default.el
@ -311,18 +351,21 @@ emacs built-in package config
**** Doom themes **** Doom themes
#+begin_src emacs-lisp :mkdirp yes :tangle ~/.config/emacs/modules/custom-ui.el #+begin_src emacs-lisp :mkdirp yes :tangle ~/.config/emacs/modules/custom-ui.el
(usr-package-install 'doom-themes) (use-package doom-themes
(require 'doom-themes) :straight (:build t)
:defer t
:init
(disable-theme 'deeper-blue) (disable-theme 'deeper-blue)
(if (display-graphic-p) (if (display-graphic-p)
(load-theme 'doom-palenight t) (load-theme 'doom-palenight t)
(load-theme 'doom-gruvbox t)) (load-theme 'doom-gruvbox t)))
#+end_src #+end_src
**** Rainbow Delimiters **** Rainbow Delimiters
#+begin_src emacs-lisp :mkdirp yes :tangle ~/.config/emacs/modules/custom-ui.el #+begin_src emacs-lisp :mkdirp yes :tangle ~/.config/emacs/modules/custom-ui.el
(usr-package-install 'rainbow-delimiters) (use-package rainbow-delimiters
(require 'rainbow-delimiters) :straight (:build t)
(add-hook 'prog-mode-hook #'rainbow-delimiters-mode) :defer t
:hook (prog-mode . rainbow-delimiters-mode))
#+end_src #+end_src
**** Setting Transparency **** Setting Transparency
#+begin_src emacs-lisp :mkdirp yes :tangle ~/.config/emacs/modules/custom-ui.el #+begin_src emacs-lisp :mkdirp yes :tangle ~/.config/emacs/modules/custom-ui.el
@ -362,36 +405,44 @@ emacs built-in package config
#+end_src #+end_src
**** Modeline **** Modeline
#+begin_src emacs-lisp :mkdirp yes :tangle ~/.config/emacs/modules/custom-ui.el #+begin_src emacs-lisp :mkdirp yes :tangle ~/.config/emacs/modules/custom-ui.el
(usr-package-install 'doom-modeline) (use-package doom-modeline
(require 'doom-modeline) :straight (:build t)
:defer t
:init (doom-modeline-mode 1)
:config
(setq doom-modeline-height 15 (setq doom-modeline-height 15
doom-modeline-env-version t doom-modeline-env-version t
doom-modeline-persp-name t doom-modeline-persp-name t
doom-modeline-persp-icon t doom-modeline-persp-icon t
doom-modeline-display-default-persp-name t doom-modeline-display-default-persp-name t
doom-modeline-indent-info t) doom-modeline-indent-info t))
(doom-modeline-mode 1)
#+end_src #+end_src
**** Visual Fill Column **** Visual Fill Column
#+begin_src emacs-lisp :mkdirp yes :tangle ~/.config/emacs/modules/custom-ui.el #+begin_src emacs-lisp :mkdirp yes :tangle ~/.config/emacs/modules/custom-ui.el
(usr-package-install 'visual-fill-column)
(require 'visual-fill-column)
(defun write-room-enable () (defun write-room-enable ()
"Write Room Enable"
(interactive)
(setq visual-fill-column-width 100 (setq visual-fill-column-width 100
visual-fill-column-center-text t) visual-fill-column-center-text t)
(visual-fill-column-mode 1)) (visual-fill-column-mode t))
(add-hook 'org-mode-hook #'write-room-enable)
(add-hook 'markdown-mode-hook #'write-room-enable)
(add-hook 'nov-mode-hook #'write-room-enable)
#+end_src
(use-package visual-fill-column
:straight (:build t)
:defer t
:hook ((org-mode markdown-mode nov-mode) . write-room-enable))
#+end_src
**** All The Icons
#+begin_src emacs-lisp :mkdirp yes :tangle ~/.config/emacs/modules/custom-ui.el
(use-package all-the-icons
:straight t)
#+end_src
**** Dashboard **** Dashboard
#+begin_src emacs-lisp :mkdirp yes :tangle ~/.config/emacs/modules/custom-ui.el #+begin_src emacs-lisp :mkdirp yes :tangle ~/.config/emacs/modules/custom-ui.el
(usr-package-install 'dashboard) (use-package dashboard
(require 'linum) ;; for dashboard seperator :straight (:build t)
;;(add-hook 'dashboard-mode page-break-lines-mode) :ensure t
(require 'dashboard) :after all-the-icons
:config
(setq dashboard-set-heading-icons t) (setq dashboard-set-heading-icons t)
(setq dashboard-set-file-icons t) (setq dashboard-set-file-icons t)
;;(setq dashboard-banner-logo-title "Emacs is more than a text editor!") ;;(setq dashboard-banner-logo-title "Emacs is more than a text editor!")
@ -399,7 +450,8 @@ emacs built-in package config
(setq dashboard-center-content t) (setq dashboard-center-content t)
(setq dashboard-week-agenda t) (setq dashboard-week-agenda t)
(setq dashboard-set-footer t) (setq dashboard-set-footer t)
(setq dashboard-page-separator "\n\f\n") (setq dashboard-page-separator "\n\n")
;;(setq dashboard-page-separator "\n\f\n")
(setq dashboard-agenda-time-string-format "%d/%m/%Y %A %H:%M") (setq dashboard-agenda-time-string-format "%d/%m/%Y %A %H:%M")
(setq dashboard-items '((recents . 10) (setq dashboard-items '((recents . 10)
(agenda . 5) (agenda . 5)
@ -427,14 +479,11 @@ emacs built-in package config
(dashboard-setup-startup-hook) (dashboard-setup-startup-hook)
(dashboard-modify-heading-icons '((recents . "file-text") (dashboard-modify-heading-icons '((recents . "file-text")
(bookmarks . "book"))) (bookmarks . "book")))
(setq initial-buffer-choice (lambda () (get-buffer-create "*dashboard*"))) (setq initial-buffer-choice (lambda () (get-buffer-create "*dashboard*"))))
#+end_src #+end_src
**** Others **** Others
#+begin_src emacs-lisp :mkdirp yes :tangle ~/.config/emacs/modules/custom-ui.el #+begin_src emacs-lisp :mkdirp yes :tangle ~/.config/emacs/modules/custom-ui.el
(usr-package-install 'all-the-icons)
(setq visible-bell t)
(defun my/self-screenshot (&optional type) (defun my/self-screenshot (&optional type)
"Save a screenshot of type TYPE of the current Emacs frame. "Save a screenshot of type TYPE of the current Emacs frame.
As shown by the function `', type can weild the value `svg', As shown by the function `', type can weild the value `svg',
@ -480,22 +529,28 @@ emacs built-in package config
**** Which keys **** Which keys
When you begin a keybind, whichkey will show you all keybinds you can follow the first one with in order to form a full keywords. When you begin a keybind, whichkey will show you all keybinds you can follow the first one with in order to form a full keywords.
#+begin_src emacs-lisp :mkdirp yes :tangle ~/.config/emacs/modules/custom-keybindings.el #+begin_src emacs-lisp :mkdirp yes :tangle ~/.config/emacs/modules/custom-keybindings.el
(usr-package-install 'which-key) (use-package which-key
(require 'which-key) :straight (:build t)
(setq which-key-idle-delay 0.5) :defer t
(which-key-mode 1) :init (which-key-mode)
:diminish which-key-mode
:config
(setq which-key-idle-delay 0.5))
#+end_src #+end_src
**** General **** General
for managing keybindings. for managing keybindings.
#+begin_src emacs-lisp :mkdirp yes :tangle ~/.config/emacs/modules/custom-keybindings.el #+begin_src emacs-lisp :mkdirp yes :tangle ~/.config/emacs/modules/custom-keybindings.el
(usr-package-install 'general) (use-package general
(require 'general) :straight (:build t)
:init
(general-auto-unbind-keys) (general-auto-unbind-keys)
:config
(general-evil-setup t) (general-evil-setup t)
(general-create-definer ju/leader-key-def (general-create-definer ju/leader-key-def
:keymaps '(normal insert visual emacs) :keymaps '(normal insert visual emacs)
:prefix "SPC" :prefix "SPC"
:global-prefix "C-SPC") :global-prefix "C-SPC"))
(ju/leader-key-def (ju/leader-key-def
"." 'find-file "." 'find-file
;; Buffer ;; Buffer
@ -528,7 +583,6 @@ for managing keybindings.
"o a" '(:ignore t :which-key "org agenda") "o a" '(:ignore t :which-key "org agenda")
"o a c" '((lambda () (interactive) (find-file (expand-file-name "agenda/agenda.org" org-directory))) :which-key "org agenda file") "o a c" '((lambda () (interactive) (find-file (expand-file-name "agenda/agenda.org" org-directory))) :which-key "org agenda file")
"o c" '(cfw:open-org-calendar :which-key "org calendar") "o c" '(cfw:open-org-calendar :which-key "org calendar")
;; Project-el ;; Project-el
"p" '(:ignore t :which-key "project") "p" '(:ignore t :which-key "project")
"p ." '(project-switch-project :which-key "switch project") "p ." '(project-switch-project :which-key "switch project")
@ -547,69 +601,83 @@ for managing keybindings.
#+end_src #+end_src
**** Evil Mode **** Evil Mode
#+begin_src emacs-lisp :mkdirp yes :tangle ~/.config/emacs/modules/custom-keybindings.el #+begin_src emacs-lisp :mkdirp yes :tangle ~/.config/emacs/modules/custom-keybindings.el
(usr-package-install 'evil) (use-package evil
(usr-package-install 'evil-collection) :straight (:build t)
(usr-package-install 'evil-nerd-commenter) :after general
(usr-package-install 'evil-numbers) :init
(customize-set-variable 'evil-want-integration t) (setq evil-want-integration t
(customize-set-variable 'evil-want-keybinding nil) evil-want-keybinding nil
(customize-set-variable 'evil-want-C-u-scroll t) evil-want-C-u-scroll t
(customize-set-variable 'evil-want-C-i-jump nil) evil-want-C-i-jump nil)
(customize-set-variable 'evil-respect-visual-line-mode nil) ; t : on the screen, nil : by cr characters ;;(setq evil-respect-visual-line-mode nil) ; t : on the screen, nil : by cr characters
(require 'evil-vars)
(customize-set-variable 'evil-set-fine-undo t); more granular undo with evil
(require 'evil)
(evil-mode 1)
;; Make evil search more like vim
;;(evil-select-search-module 'evil-search-module 'evil-search)
(evil-set-undo-system 'undo-tree) (evil-set-undo-system 'undo-tree)
;;(evil-set-undo-system 'undo-redo) ;;(evil-set-undo-system 'undo-redo)
;; Make evil search more like vim (makes emacs slow)
;;(evil-select-search-module 'evil-search-module 'evil-search)
:config
(evil-mode 1)
(setq evil-want-fine-undo t) ; more granular undo with evil
(evil-set-initial-state 'messages-buffer-mode 'normal) (evil-set-initial-state 'messages-buffer-mode 'normal)
(evil-set-initial-state 'dashboard-mode 'normal) (evil-set-initial-state 'dashboard-mode 'normal)
;; eshell no evil
(dolist (mode '(eshell-mode))
(add-to-list 'evil-emacs-state-modes mode)))
(use-package evil-collection
:after evil
:straight (:build t)
:config
(evil-collection-init))
(use-package evil-nerd-commenter
:after evil
:straight (:build t)
:config
;; evil nerd commenter ;; evil nerd commenter
(define-key evil-normal-state-map (kbd "g c") 'evilnc-comment-or-uncomment-lines) (define-key evil-normal-state-map (kbd "g c") 'evilnc-comment-or-uncomment-lines)
(define-key evil-visual-state-map (kbd "g c") 'evilnc-comment-or-uncomment-lines) (define-key evil-visual-state-map (kbd "g c") 'evilnc-comment-or-uncomment-lines))
;; evil collection
(evil-collection-init)
(use-package evil-numbers
:after evil
:straight (:build t)
:config
;; evil numbers ;; evil numbers
;; unfortunately C-x is emacs common key binding. ;; unfortunately C-x is emacs common key binding.
(define-key evil-normal-state-map (kbd "g =") 'evil-numbers/inc-at-pt) (define-key evil-normal-state-map (kbd "g =") 'evil-numbers/inc-at-pt)
(define-key evil-normal-state-map (kbd "g -") 'evil-numbers/dec-at-pt) (define-key evil-normal-state-map (kbd "g -") 'evil-numbers/dec-at-pt)
(define-key evil-visual-state-map (kbd "g =") 'evil-numbers/inc-at-pt) (define-key evil-visual-state-map (kbd "g =") 'evil-numbers/inc-at-pt)
(define-key evil-visual-state-map (kbd "g -") 'evil-numbers/dec-at-pt) (define-key evil-visual-state-map (kbd "g -") 'evil-numbers/dec-at-pt))
;; eshell no evil
(dolist (mode '(eshell-mode))
(add-to-list 'evil-emacs-state-modes mode))
;; when programming _
(modify-syntax-entry ?_ "w")
#+end_src #+end_src
**** Undo Tree **** Undo Tree
#+begin_src emacs-lisp :mkdirp yes :tangle ~/.config/emacs/modules/custom-keybindings.el #+begin_src emacs-lisp :mkdirp yes :tangle ~/.config/emacs/modules/custom-keybindings.el
(usr-package-install 'undo-tree) (use-package undo-tree
(require 'undo-tree) :straight (:build t)
:defer t
:custom
(undo-tree-history-directory-alist
`(("." . ,(expand-file-name (file-name-as-directory "undo-tree-hist")
user-emacs-directory))))
:init
(global-undo-tree-mode)
:config
(setq undo-tree-visualizer-diff t (setq undo-tree-visualizer-diff t
undo-tree-visualizer-timestamps t undo-tree-visualizer-timestamps t
undo-tree-auto-save-history t undo-tree-auto-save-history t
undo-tree-enable-undo-in-region t undo-tree-enable-undo-in-region t
undo-limit (* 800 1024) undo-limit (* 800 1024)
undo-strong-limit (* 12 1024 1024) undo-strong-limit (* 12 1024 1024)
undo-outer-limit (* 128 1024 1024)) undo-outer-limit (* 128 1024 1024)))
(setq undo-tree-history-directory-alist
`(("." . ,(expand-file-name (file-name-as-directory "undo-tree-hist")
user-emacs-directory))))
(global-undo-tree-mode)
#+end_src #+end_src
**** Hydra **** Hydra
#+begin_src emacs-lisp :mkdirp yes :tangle ~/.config/emacs/modules/custom-keybindings.el #+begin_src emacs-lisp :mkdirp yes :tangle ~/.config/emacs/modules/custom-keybindings.el
(usr-package-install 'hydra) (use-package hydra
(require 'hydra) :straight (:build t)
:defer t)
(defhydra hydra-text-scale (:timeout 4) (defhydra hydra-text-scale (:timeout 4)
"scale text" "scale text"
("t" text-scale-increase "in") ("t" text-scale-increase "in")
@ -644,82 +712,115 @@ config from crafted-emacs
https://github.com/SystemCrafters/crafted-emacs https://github.com/SystemCrafters/crafted-emacs
**** Vertico **** Vertico
#+begin_src emacs-lisp :mkdirp yes :tangle ~/.config/emacs/modules/custom-completion.el #+begin_src emacs-lisp :mkdirp yes :tangle ~/.config/emacs/modules/custom-completion.el
(usr-package-install 'vertico) (use-package vertico
(require 'vertico) :straight (:build t)
(require 'vertico-directory) :bind (:map vertico-map
(with-eval-after-load 'evil ("C-j" . vertico-next)
(define-key vertico-map (kbd "C-j") 'vertico-next) ("C-k" . vertico-previous))
(define-key vertico-map (kbd "C-k") 'vertico-previous) :custom
(define-key vertico-map (kbd "M-h") 'vertico-directory-up)) (vertico-cycle t)
(customize-set-variable 'vertico-cycle t) :init
(vertico-mode 1) (vertico-mode))
;;(use-package vertico
;; :straight (:build t)
;; :ensure t
;; :bind (:map vertico-map
;; ("C-j" 'vertico-next)
;; ("C-k" 'vertico-previous)
;; ("M-h" 'vertico-directory-up))
;; :custom
;; (vertico-cycle t)
;; :config
;; (vertico-mode))
#+end_src #+end_src
**** Prescient **** Prescient
simple but effective sorting and filtering for emacs. simple but effective sorting and filtering for emacs.
#+begin_src emacs-lisp :mkdirp yes :tangle ~/.config/emacs/modules/custom-completion.el #+begin_src emacs-lisp :mkdirp yes :tangle ~/.config/emacs/modules/custom-completion.el
(usr-package-install 'vertico-prescient) (use-package vertico-prescient
(vertico-prescient-mode) :straight (:build t)
:defer t
:config
(vertico-prescient-mode))
#+end_src #+end_src
**** Marginalia **** Marginalia
annotations placed at the margin of the minibuffer annotations placed at the margin of the minibuffer
#+begin_src emacs-lisp :mkdirp yes :tangle ~/.config/emacs/modules/custom-completion.el #+begin_src emacs-lisp :mkdirp yes :tangle ~/.config/emacs/modules/custom-completion.el
(usr-package-install 'marginalia) (use-package vertico-prescient
(require 'marginalia) :straight (:build t)
(customize-set-variable 'marginalia-annotators '(marginalia-annotators-heavy marginalia-annotators-light nil)) :defer t
(marginalia-mode 1) :custom (marginalia-annotators '(marginalia-annotators-heavy marginalia-annotators-light nil))
:config (marginalia-mode 1))
#+end_src #+end_src
**** Consult **** Consult
#+begin_src emacs-lisp :mkdirp yes :tangle ~/.config/emacs/modules/custom-completion.el #+begin_src emacs-lisp :mkdirp yes :tangle ~/.config/emacs/modules/custom-completion.el
(usr-package-install 'consult) (use-package consult
:straight (:build t)
:demand t
:bind (:map minibuffer-local-map
("C-r" . consult-history))
:custom
(completion-in-region-function #'consult-completion-in-region)
:config
(global-set-key (kbd "C-s") 'consult-line) (global-set-key (kbd "C-s") 'consult-line)
(define-key minibuffer-local-map (kbd "C-r") 'consult-history) (global-set-key (kbd "C-M-j") 'consult-buffer))
(global-set-key (kbd "C-M-j") 'consult-buffer)
(setq completion-in-region-function #'consult-completion-in-region)
#+end_src #+end_src
**** Orderless **** Orderless
orderless completion orderless completion
#+begin_src emacs-lisp :mkdirp yes :tangle ~/.config/emacs/modules/custom-completion.el #+begin_src emacs-lisp :mkdirp yes :tangle ~/.config/emacs/modules/custom-completion.el
(usr-package-install 'orderless) (use-package orderless
(require 'orderless) :straight (:build t)
(customize-set-variable 'completion-styles '(orderless basic)) :defer t
(customize-set-variable 'completion-category-overrides '((file (style basic partial-completion)))) :custom
(completion-styles '(orderless basic))
(completion-category-overrides '((file (style basic partial-completion)))))
#+end_src #+end_src
**** Embark / Embark Consult **** Embark / Embark Consult
Quick Action in minibuffer Quick Action in minibuffer
#+begin_src emacs-lisp :mkdirp yes :tangle ~/.config/emacs/modules/custom-completion.el #+begin_src emacs-lisp :mkdirp yes :tangle ~/.config/emacs/modules/custom-completion.el
(usr-package-install 'embark) (use-package embark
(usr-package-install 'embark-consult) :straight (:build t)
(require 'embark) :defer t
(require 'embark-consult) :bind (("C-." . embark-act))
(global-set-key [remap describe-bindings] #'embark-bindings) :config
(global-set-key (kbd "C-.") 'embark-act)
;; Use Embark to show bindings in a key prefix with `C-h`
(setq prefix-help-command #'embark-prefix-help-command)
(with-eval-after-load 'embark-consult (with-eval-after-load 'embark-consult
(add-hook 'embark-collect-mode-hook #'consult-preview-at-point-mode)) (add-hook 'embark-collect-mode-hook #'consult-preview-at-point-mode))
(global-set-key [remap describe-bindings] #'embark-bindings)
;; Use Embark to show bindings in a key prefix with `C-h`
(setq prefix-help-command #'embark-prefix-help-command))
(use-package embark-consult
:straight (:build t)
:defer t
:after embark)
#+end_src #+end_src
**** Corfu / Cape **** Corfu / Cape
#+begin_src emacs-lisp :mkdirp yes :tangle ~/.config/emacs/modules/custom-completion.el #+begin_src emacs-lisp :mkdirp yes :tangle ~/.config/emacs/modules/custom-completion.el
(usr-package-install 'corfu)
(usr-package-install 'corfu-terminal)
(usr-package-install 'cape)
;;; Corfu ;;; Corfu
(use-package corfu
:straight (:build t)
:defer t
:custom
(corfu-cycle t) ;; Enable cycling for `corfu-next/previous'
(corfu-auto t) ;; Enable auto completion
(corfu-auto-prefix 2)
(corfu-auto-delay 0.0)
(corfu-echo-documentation 0.25)
;; (corfu-separator ?\s) ;; Orderless field separator
;; (corfu-quit-at-boundary nil) ;; Never quit at completion boundary
;; (corfu-quit-no-match nil) ;; Never quit, even if there is no match
;; (corfu-preview-current nil) ;; Disable current candidate preview
;; (corfu-preselect 'prompt) ;; Preselect the prompt
;; (corfu-on-exact-match nil) ;; Configure handling of exact matches
;; (corfu-scroll-margin 5) ;; Use scroll margin
:init
(global-corfu-mode))
;; load extension
(add-to-list 'load-path
(expand-file-name "straight/build/corfu/extensions"
straight-base-dir))
(require 'corfu-popupinfo) (require 'corfu-popupinfo)
(require 'corfu)
(unless (display-graphic-p)
(require 'corfu-terminal)
(corfu-terminal-mode +1))
;; Setup corfu for popup like completion
(customize-set-variable 'corfu-cycle t) ; Allows cycling through candidates
(customize-set-variable 'corfu-auto t) ; Enable auto completion
(customize-set-variable 'corfu-auto-prefix 2) ; Complete with less prefix keys
(customize-set-variable 'corfu-auto-delay 0.0) ; No delay for completion
(customize-set-variable 'corfu-echo-documentation 0.25) ; Echo docs for current completion option
(global-corfu-mode 1)
(corfu-popupinfo-mode 1) (corfu-popupinfo-mode 1)
(eldoc-add-command #'corfu-insert) (eldoc-add-command #'corfu-insert)
(define-key corfu-map (kbd "M-p") #'corfu-popupinfo-scroll-down) (define-key corfu-map (kbd "M-p") #'corfu-popupinfo-scroll-down)
@ -727,18 +828,17 @@ Quick Action in minibuffer
(define-key corfu-map (kbd "M-d") #'corfu-popupinfo-toggle) (define-key corfu-map (kbd "M-d") #'corfu-popupinfo-toggle)
;;; Cape ;;; Cape
;; Setup Cape for better completion-at-point support and more ;; Setup Cape for better completion-at-point support and more
(require 'cape) (use-package cape
:straight (:build t)
:defer t
:config
;; Add useful defaults completion sources from cape ;; Add useful defaults completion sources from cape
(add-to-list 'completion-at-point-functions #'cape-file) (add-to-list 'completion-at-point-functions #'cape-file)
(add-to-list 'completion-at-point-functions #'cape-dabbrev) (add-to-list 'completion-at-point-functions #'cape-dabbrev)
;; Silence the pcomplete capf, no errors or messages! ;; Silence the pcomplete capf, no errors or messages!
;; Important for corfu ;; Important for corfu
(advice-add 'pcomplete-completions-at-point :around #'cape-wrap-silent) (advice-add 'pcomplete-completions-at-point :around #'cape-wrap-silent)
;; Ensure that pcomplete does not write to the buffer ;; Ensure that pcomplete does not write to the buffer
;; and behaves as a pure `completion-at-point-function'. ;; and behaves as a pure `completion-at-point-function'.
(advice-add 'pcomplete-completions-at-point :around #'cape-wrap-purify) (advice-add 'pcomplete-completions-at-point :around #'cape-wrap-purify)
@ -746,7 +846,10 @@ Quick Action in minibuffer
(lambda () (setq-local corfu-quit-at-boundary t (lambda () (setq-local corfu-quit-at-boundary t
corfu-quit-no-match t corfu-quit-no-match t
corfu-auto nil) corfu-auto nil)
(corfu-mode))) (corfu-mode))))
(unless (display-graphic-p)
(require 'corfu-terminal)
(corfu-terminal-mode +1))
#+end_src #+end_src
**** Provide Modules **** Provide Modules
#+begin_src emacs-lisp :mkdirp yes :tangle ~/.config/emacs/modules/custom-completion.el #+begin_src emacs-lisp :mkdirp yes :tangle ~/.config/emacs/modules/custom-completion.el