vertico: various refactors...
- unify `map!` statements when possible - rename `+vertico--embark-target-package!` to `+vertico--embark-target-package` and autoload it - set `completion-in-region-function` to a wrapper function instead of changing it with a hook - use `:override` advice instead of `fset` for `multi-occur` - document what `vertico-directory-tidy` does - move `:init` contents to `:config` when possible
This commit is contained in:
parent
770084fdda
commit
3f1016753d
2 changed files with 40 additions and 38 deletions
|
@ -92,6 +92,15 @@ If ARG (universal argument), include all files, even hidden or compressed ones."
|
||||||
(expand-file-name new-path))))))
|
(expand-file-name new-path))))))
|
||||||
(call-interactively 'backward-delete-char))))
|
(call-interactively 'backward-delete-char))))
|
||||||
|
|
||||||
|
(defun +vertico--embark-target-package ()
|
||||||
|
"Targets Doom's package! statements and returns the package name"
|
||||||
|
(when (or (derived-mode-p 'emacs-lisp-mode) (derived-mode-p 'org-mode))
|
||||||
|
(save-excursion
|
||||||
|
(search-backward "(")
|
||||||
|
(when (looking-at "(\\s-*package!\\s-*\\(\\(\\sw\\|\\s_\\)+\\)\\s-*")
|
||||||
|
(let ((pkg (match-string 1)))
|
||||||
|
(set-text-properties 0 (length pkg) nil pkg)
|
||||||
|
`(package . ,pkg))))))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun +vertico/embark-export-write ()
|
(defun +vertico/embark-export-write ()
|
||||||
|
|
|
@ -2,16 +2,18 @@
|
||||||
|
|
||||||
(use-package! vertico
|
(use-package! vertico
|
||||||
:hook (doom-first-input . vertico-mode)
|
:hook (doom-first-input . vertico-mode)
|
||||||
:init
|
:config
|
||||||
(setq vertico-resize nil
|
(setq vertico-resize nil
|
||||||
vertico-count 17
|
vertico-count 17
|
||||||
vertico-cycle t)
|
vertico-cycle t)
|
||||||
(add-hook 'vertico-mode-hook (lambda ()
|
(setq completion-in-region-function
|
||||||
(setq completion-in-region-function
|
(lambda (&rest args)
|
||||||
(if vertico-mode
|
(apply (if vertico-mode
|
||||||
#'consult-completion-in-region
|
#'consult-completion-in-region
|
||||||
#'completion--in-region))))
|
#'completion--in-region)
|
||||||
:config
|
args)))
|
||||||
|
;; cleans up path when moving directories with shadowed paths syntax,
|
||||||
|
;; e.g. cleans ~/foo/bar/// to /, and ~/foo/bar/~/ to ~/.
|
||||||
(add-hook 'rfn-eshadow-update-overlay-hook #'vertico-directory-tidy)
|
(add-hook 'rfn-eshadow-update-overlay-hook #'vertico-directory-tidy)
|
||||||
(map! :map vertico-map
|
(map! :map vertico-map
|
||||||
[backspace] #'+vertico/backward-updir))
|
[backspace] #'+vertico/backward-updir))
|
||||||
|
@ -47,7 +49,7 @@
|
||||||
(use-package! consult
|
(use-package! consult
|
||||||
:defer t
|
:defer t
|
||||||
:init
|
:init
|
||||||
(fset 'multi-occur #'consult-multi-occur)
|
(advice-add #'multi-occur :override #'consult-multi-occur)
|
||||||
(define-key!
|
(define-key!
|
||||||
[remap apropos] #'consult-apropos
|
[remap apropos] #'consult-apropos
|
||||||
[remap bookmark-jump] #'consult-bookmark
|
[remap bookmark-jump] #'consult-bookmark
|
||||||
|
@ -99,31 +101,22 @@
|
||||||
|
|
||||||
(use-package! embark
|
(use-package! embark
|
||||||
:init
|
:init
|
||||||
|
(map! "C-;" #'embark-act ; to be moved to :config default if accepted
|
||||||
|
:map minibuffer-local-map
|
||||||
|
"C-;" #'embark-act
|
||||||
|
"C-c C-;" #'embark-export
|
||||||
|
:desc "Export to writable buffer"
|
||||||
|
"C-c C-e" #'+vertico/embark-export-write
|
||||||
|
:leader
|
||||||
|
:desc "Actions" "a" #'embark-act) ; to be moved to :config default if accepted
|
||||||
|
(define-key!
|
||||||
|
[remap describe-bindings] #'embark-bindings)
|
||||||
|
:config
|
||||||
(setq embark-action-indicator
|
(setq embark-action-indicator
|
||||||
(lambda (map _target)
|
(lambda (map _target)
|
||||||
(which-key--show-keymap "Embark" map nil nil 'no-paging)
|
(which-key--show-keymap "Embark" map nil nil 'no-paging)
|
||||||
#'which-key--hide-popup-ignore-command)
|
#'which-key--hide-popup-ignore-command)
|
||||||
embark-become-indicator embark-action-indicator)
|
embark-become-indicator embark-action-indicator)
|
||||||
(map! "C-;" #'embark-act ; to be moved to :config default if accepted
|
|
||||||
:leader
|
|
||||||
:desc "Actions" "a" #'embark-act) ; to be moved to :config default if accepted
|
|
||||||
(map! :map minibuffer-local-map
|
|
||||||
"C-;" #'embark-act
|
|
||||||
"C-c C-;" #'embark-export
|
|
||||||
:desc "Export to writable buffer"
|
|
||||||
"C-c C-e" #'+vertico/embark-export-write)
|
|
||||||
(define-key!
|
|
||||||
[remap describe-bindings] #'embark-bindings)
|
|
||||||
(defun +vertico--embark-target-package! ()
|
|
||||||
"Targets Doom's package! statements and returns the package name"
|
|
||||||
(when (or (derived-mode-p 'emacs-lisp-mode) (derived-mode-p 'org-mode))
|
|
||||||
(save-excursion
|
|
||||||
(search-backward "(")
|
|
||||||
(when (looking-at "(\\s-*package!\\s-*\\(\\(\\sw\\|\\s_\\)+\\)\\s-*")
|
|
||||||
(let ((pkg (match-string 1)))
|
|
||||||
(set-text-properties 0 (length pkg) nil pkg)
|
|
||||||
`(package . ,pkg))))))
|
|
||||||
:config
|
|
||||||
;; add the package! target finder before the file target finder,
|
;; add the package! target finder before the file target finder,
|
||||||
;; so we don't get a false positive match.
|
;; so we don't get a false positive match.
|
||||||
(let ((pos (or (cl-position
|
(let ((pos (or (cl-position
|
||||||
|
@ -132,28 +125,28 @@
|
||||||
(length embark-target-finders))))
|
(length embark-target-finders))))
|
||||||
(cl-callf2
|
(cl-callf2
|
||||||
cons
|
cons
|
||||||
'+vertico--embark-target-package!
|
'+vertico--embark-target-package
|
||||||
(nthcdr pos embark-target-finders)))
|
(nthcdr pos embark-target-finders)))
|
||||||
|
(setq embark-package-map (make-sparse-keymap))
|
||||||
(map!
|
(map!
|
||||||
:map embark-file-map
|
:map embark-file-map
|
||||||
:desc "Open target with sudo" "s" #'doom/sudo-find-file
|
:desc "Open target with sudo" "s" #'doom/sudo-find-file
|
||||||
:desc "Open in new workspace" "TAB" #'+vertico-embark-open-in-new-workspace)
|
:desc "Open in new workspace" "TAB" #'+vertico-embark-open-in-new-workspace
|
||||||
(setq embark-package-map (make-sparse-keymap))
|
:map embark-package-map
|
||||||
(map! :map embark-package-map
|
"h" #'doom/help-packages
|
||||||
"h" #'doom/help-packages
|
"b" #'doom/bump-package
|
||||||
"b" #'doom/bump-package
|
"c" #'doom/help-package-config
|
||||||
"c" #'doom/help-package-config
|
"u" #'doom/help-package-homepage))
|
||||||
"u" #'doom/help-package-homepage))
|
|
||||||
|
|
||||||
(use-package! marginalia
|
(use-package! marginalia
|
||||||
:hook (doom-first-input . marginalia-mode)
|
:hook (doom-first-input . marginalia-mode)
|
||||||
:init
|
:init
|
||||||
(when (featurep! +icons)
|
|
||||||
(add-hook 'marginalia-mode-hook #'all-the-icons-completion-marginalia-setup))
|
|
||||||
(map! :map minibuffer-local-map
|
(map! :map minibuffer-local-map
|
||||||
:desc "Cycle marginalia views"
|
:desc "Cycle marginalia views"
|
||||||
"M-A" #'marginalia-cycle)
|
"M-A" #'marginalia-cycle)
|
||||||
:config
|
:config
|
||||||
|
(when (featurep! +icons)
|
||||||
|
(add-hook 'marginalia-mode-hook #'all-the-icons-completion-marginalia-setup))
|
||||||
(nconc marginalia-command-categories
|
(nconc marginalia-command-categories
|
||||||
'((persp-switch-to-buffer . buffer)
|
'((persp-switch-to-buffer . buffer)
|
||||||
(projectile-find-file . project-file)
|
(projectile-find-file . project-file)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue