completion/selectrum -> completion/vertico, part 2

- Rename module from `:completion selectrum` to `:completion vertico`
- Rename all files involved
- Do *not* yet rename all the functions, as that messes up git's rename
  detection.
This commit is contained in:
Itai Y. Efrat 2021-07-09 20:16:11 +03:00
parent f9e1c99b2b
commit 24eaa1317c
33 changed files with 79 additions and 90 deletions

View file

@ -0,0 +1,178 @@
#+TITLE: completion/vertico
#+DATE: February 16, 2021
#+SINCE: v3.0.0
#+STARTUP: inlineimages
* Table of Contents :TOC_2:noexport:
- [[#description][Description]]
- [[#module-flags][Module Flags]]
- [[#plugins][Plugins]]
- [[#prerequisites][Prerequisites]]
- [[#features][Features]]
- [[#jump-to-navigation][Jump-to navigation]]
- [[#project-search--replace][Project search & replace]]
- [[#in-buffer-searching][In-buffer searching]]
- [[#vertico-integration-for-various-completing-commands][Vertico integration for various completing commands]]
- [[#orderless-filtering][Orderless filtering]]
* Description
This module provides Vertico integration for a variety of Emacs commands, as
well as a unified interface for project search and replace, powered by ripgrep.
#+begin_quote
TODO
#+end_quote
** Module Flags
+ ~+icons~ Adds icons to ~file~ and ~buffer~ category completion selections.
** Plugins
[[https://github.com/minad/vertico][vertico]]
[[https://github.com/minad/consult][consult]]
[[https://github.com/oantolin/embark/][embark]]
[[https://github.com/oantolin/embark/][embark-consult]]
[[https://github.com/minad/marginalia][marginalia]]
[[https://github.com/oantolin/orderless][orderless]]
[[https://github.com/mhayashi1120/Emacs-wgrep][wgrep]]
[[https://github.com/minad/consult/][consult-flycheck]] (~:checkers syntax~)
[[https://github.com/iyefrat/all-the-icons-completion][all-the-icons-completion]] (~+icons~)
* Prerequisites
This module has no prerequisites.
* Features
The packages in this module modify and use the built-in ~completing-read~
function, which is used by any function that requires completion. Due to this
the full scope of these packages is too large to cover here and you are
encouraged to go and read their excellent documentation. We will detail
Doom-specific additions:
** Jump-to navigation
This module provides an interface to navigate within a project using
=projectile=:
https://assets.doomemacs.org/completion/vertico/projectile.png
| Keybind | Description |
|----------------------+-------------------------------------|
| =SPC p f=, =SPC SPC= | Jump to file in project |
| =SPC f f=, =SPC .= | Jump to file from current directory |
| =SPC s i= | Jump to symbol in file |
** Project search & replace
This module provides interactive text search and replace using ripgrep.
| Keybind | Description |
|-----------+--------------------------|
| =SPC s p= | Search project |
| =SPC s P= | Search another project |
| =SPC s d= | Search this directory |
| =SPC s D= | Search another directory |
https://assets.doomemacs.org/completion/vertico/search.png
Prefixing these keys with the universal argument (=SPC u= for evil users; =C-u=
otherwise) changes the behavior of these commands, instructing the underlying
search engine to include ignored files.
This module also provides Ex Commands for evil users:
| Ex command | Description |
|------------------------+------------------------------------------------------------------|
| ~:pg[rep][!] [QUERY]~ | Search project (if ~!~, include hidden files) |
| ~:pg[rep]d[!] [QUERY]~ | Search from current directory (if ~!~, don't search recursively) |
The optional `!` is equivalent to the universal argument for the previous
commands.
-----
These keybindings are available while a search is active:
| Keybind | Description |
|---------------------+----------------------------------------------------|
| =C-;=, =<leader> a= | Open an ~embark-act~ menu to chose a useful action |
| =C-c C-;= | Open a buffer with your search results |
| =C-c C-e= | Open a writable buffer of your search results |
| =C-SPC= | Preview the current candidate |
| =C-M-j= | Scroll down and preview. |
| =C-M-k= | Scroll up and preview. |
| =C-RET= | Open the selected candidate in other-window |
Changes to the resulting wgrep buffer (opened by =C-c C-e=) can be committed
with =C-c C-c= and aborted with =C-c C-k= (alternatively =ZZ= and =ZQ=, for evil
users).
https://assets.doomemacs.org/completion/vertico/search-replace.png
** In-buffer searching
This module provides some in buffer searching bindings:
+ =SPC s s= (~isearch~)
+ =SPC s S= (~+selectrum/search-symbol-at-point~ via ~consult-line~)
+ =SPC s b= (~consult-line~)
https://assets.doomemacs.org/completion/vertico/buffer-search.png
An ~occur-edit~ buffer can be opened from ~consult-line~ with =C-c C-e=.
** Vertico integration for various completing commands
*** General
| Keybind | Description |
|----------------+-----------------------------|
| =M-x=, =SPC := | Enhanced M-x |
| =SPC '= | Resume last Vertico session |
*** Jump to files, buffers or projects
| Keybind | Description |
|----------------------+---------------------------------------|
| =SPC RET= | Find bookmark |
| =SPC f f=, =SPC .= | Browse from current directory |
| =SPC p f=, =SPC SPC= | Find file in project |
| =SPC f r= | Find recently opened file |
| =SPC p p= | Open another project |
| =SPC b b=, =SPC ,= | Switch to buffer in current workspace |
| =SPC b B=, =SPC <= | Switch to buffer |
=SPC b b= and =SPC ,= support changing the workspace you're selecting a buffer from
via [[https://github.com/minad/consult#narrowing-and-grouping][Consult narrowing]], e.g. if you're on the first workspace, you can switch to
selecting a buffer from the third workspace by typing =3 SPC= into the prompt,
or the last workspace by typing =0 SPC=.
=SPC f f= and =SPC .= support exporting to a =wdired= buffer using =C-c C-e=.
*** Search
| Keybind | Description |
|-----------+-------------------------------------------|
| =SPC p t= | List all TODO/FIXMEs in project |
| =SPC s b= | Search the current buffer |
| =SPC s d= | Search this directory |
| =SPC s D= | Search another directory |
| =SPC s i= | Search for symbol in current buffer |
| =SPC s p= | Search project |
| =SPC s P= | Search another project |
| =SPC s s= | Search the current buffer (incrementally) |
** Orderless filtering
When using orderless to filter through candidates, the default behaviour is for
each space separated input to match the candidate as a regular expression or
literally.
Note that due to this style of matching, pressing tab does not expand the input
to the longest matching prefix (like shell completion), but rather uses the
first matched candidate as input. Filtering further is instead achieved by
pressing space and entering another input. In essence, when trying to match
=foobar.org=, instead of option 1., use option 2.:
1. (BAD) Enter =foo TAB=, completes to =foobar.=, enter =org RET=
2. (GOOD) Enter =foo SPC org RET=
Doom has some builtin [[https://github.com/oantolin/orderless#style-dispatchers][style dispatchers]] for more finegrained filtering, which
you can use to further specify each space separated input in the following ways:
| Input | Description |
|------------------+--------------------------------------------|
| =!foo= | match without literal input =foo= |
| =`bar= or =bar`= | match input =bar= as an initialism |
| ==baz= or =baz== | match only with literal input =baz= |
| =~qux= or =qux~= | match input =qux= with fuzzy/flex matching |

View file

@ -0,0 +1,112 @@
* PROJ Design Decisions
** TODO Bind =consult-lsp-diagnostics= to something?
** TODO Finalize =embark-act= keybindings
They are currently set to =C-;= and =<leader> a=. The motivation for this is as
follows:
*** =C-;=
Least intrusive key-chord type binding I could find. Doesn't interfere with
other keybindings for the most part (unlike =C-o= which clashes for in
minibuffer =evil-want-minibuffer= users and regular buffer evil users), with the
exception of:
- =C-;= is bound to ~flyspell-auto-correct-previous-word~. via the built in
flyspell map.
- =C-;= is bound to ~+company/complete~ in the vanilla emacs bindings.
We could also just bind it in the minibuffer if we do end up going with the
leader key.
*** Alternative chord: =C-,=
Still has some overlaps, but perhaps less important:
- ~flyspell-goto-next-error~
- ~org-cycle-agenda-files~ has redundancy in =C-'= anyway.
It is however less convenient than =C-;=
*** =<leader> a=
Even though top level module dependant bindings are frowned upon, here is my
case for why this should be an exception:
- It provide a useful shortcut for a bunch of commands relevant to the symbol at
point, and seems to be better at this than built in stuff, e.g. doing
=<leader> f D= to delete a file in =eshell= doesn't work, but embark
recognises that it's a file, so =<leader> a d= does.
- other than helping with discoverability for stuff this also allows for
commands for things that are too niche for top level bindings, such as actions
on ~package!~ statements and recipes or urls.
- vertico is slated to become the default completion module, which makes this
less of an inconsistency, but I'm not sure about the performance slowdown in
~map!~ since that seems to be one of the main concerns.
- ~embark~ like most packages in the vertico cinematic universe can be
installed independently, so if you find it sufficiently useful you could also
have a stripped down version of the config in doom core that is just used for
on-buffer actions.
** TODO =SPC s s= and =SPC s S= ~:sw~ ?
There isn't really a vertico/consult analogue to ~swiper-isearch~, ~consult-isearch~
does something else (give you previously used isearch search terms). Bound to
regular isearch for now.
** TODO =SPC s B=
Vertico/Consult don't have a ~swiper-all~ analogue either. Unbound for now.
** TODO Orderless style dispatchers
Currently the =!= style dispatcher is only as a prefix, due to the abundance of
=!= final macros. In my opinion this is useful enough to break consistency.
** TODO =C-c C-e=
On ~consult-line~ this opens a ~occur-edit~ buffer, which is a more natural fit
but breaks slightly from the =C-c C-e= = =wgrep= convention.
** TODO Keep or discard =C-M-j= and =C-M-k=
Scroll up and down while previewing. Essentially shortcuts for =C-(j|k) C-SPC=.
I like having them around but I can always just add them to my private config.
** TODO Annotation Customization
Do we want to have the annotations be more like ivy? e.g.
- Have a project column in the buffer annotations and a relative path? This has
some overlap with project narrowing =SPC b B p SPC.
- Mark the modified/remote status of the buffer with color, on top of the
modification column?
- Change colors in general?
* PROJ HACKs to be addressed
** TODO ~fboundp~ issues
Even if the =ivy= module isn't loaded, it's packages can still get loaded by
other means, such as =lispy= requiring =counsel=. This means that the ~fboundp~
logic [[file:~/.emacs.d/modules/config/default/autoload/text.el::(cond ((fboundp 'consult-yank-pop) #'consult-yank-pop) ;;HACK see @ymarco's comment on #5013 and TODO.org][here]] (and formerly [[file:~/.emacs.d/core/autoload/projects.el::(and (bound-and-true-p ivy-mode][here]]) won't work unless the vertico option is checked
first, which is what we do for now.
** TODO ~projectile-switch-project-action~ definition
Without [[file:~/.emacs.d/modules/ui/workspaces/config.el::;; HACK?? needs review][this]] change new projects don't get opened in a new tab, but the exact
working of this whole set up are a bit opaque to me.
* PROJ Review blocking Issues
** TODO Embark export window buffer switching logic
*** DONE ~grep~
The clicking links exported grep buffers used to open in a new window, but now
open in another window. Caused by the ~set-popup-rule!~ entries for the embark
export/collect buffers. These don't seem to serve much of a purpose at this
point so they have been removed.
*** TODO Open upstream Embark issue for ~bookmark~ and ~file~
~bookmark~ or ~file~ export buffers open the links in the same window rather than
the other one. This can be reproduces on emacs -Q.
This is due to orderless adding a bunch of other matches.
* PROJ Review non-blocking Issues
** TODO Profile vertico =SPC /= vs ivy =SPC /=
Check if there are other places where optimisations can be made. Perhaps the
~command-input-async~ variables can tolorate lower values.
** TODO ~(defadvice! +orderless-match-with-one-face..~ causes lexical error
Probably caused by some doomism
https://github.com/oantolin/orderless/issues/41
* PROJ Extra credit
** ~vertico-repeat~ doesn't reselect the candidate
** TODO =bibtex-actions= improvements?
Currently =SPC n b= is bound to a function, but =bibtex-actions= doesn't have a
main dispatch function like =ivy-bibtex=, rather it has a bunch of different
ones. Binding the ~bibtex-actions-map~ there would probably be better, but there
are nontrivial loading order shenanigans happening that make that not
straightforward.
** TODO Buffer switching
- =SPC b b= should switch workspace after choosing a buffer from a different one
- Universal argument for opening buffer in another window?
** TODO Ivy Parity
*** TODO =C-RET= on minibuffer?
*** TODO pass module
*** TODO ~+ivy/jump-list~ analogue
*** WAIT lookup module
- ~dash-docs~ backend (needs to be created)
- ~+lookup--online..~ functionality (needs a consult analogue of
~counsel-search~)
*** WAIT taskrunner module
in all likelihood requires writing ~consult-taskrunner~.

View file

@ -0,0 +1,14 @@
;; completion/vertico/autoload/evil.el -*- lexical-binding: t; -*-
;;;###if (featurep! :editor evil)
;;;###autoload (autoload '+selectrum:project-search "completion/vertico/autoload/evil" nil t)
(evil-define-command +selectrum:project-search (query &optional all-files-p)
"Ex interface for `+selectrum/project-search'."
(interactive "<a><!>")
(+selectrum/project-search all-files-p query))
;;;###autoload (autoload '+selectrum:project-search-from-cwd "completion/vertico/autoload/evil" nil t)
(evil-define-command +selectrum:project-search-from-cwd (query &optional recurse-p)
"Ex interface for `+selectrum/project-search-from-cwd'."
(interactive "<a><!>")
(+selectrum/project-search-from-cwd (not recurse-p) query))

View file

@ -0,0 +1,135 @@
;;; completion/vertico/autoload/vertico.el -*- lexical-binding: t; -*-
;;;###autoload
(defadvice! +selectrum--company-capf--candidates-a (fn &rest args)
"Highlight company matches correctly, and try default completion styles before
orderless."
:around 'company-capf--candidates
(let ((orderless-match-faces [completions-common-part])
(completion-styles '(basic partial-completion orderless)))
(apply fn args)))
;;;###autoload
(cl-defun +selectrum-file-search (&key query in all-files (recursive t) prompt args)
"Conduct a file search using ripgrep.
:query STRING
Determines the initial input to search for.
:in PATH
Sets what directory to base the search out of. Defaults to the current project's root.
:recursive BOOL
Whether or not to search files recursively from the base directory."
(declare (indent defun))
(unless (executable-find "rg")
(user-error "Couldn't find ripgrep in your PATH"))
(require 'consult)
(setq deactivate-mark t)
(let* ((project-root (or (doom-project-root) default-directory))
(directory (or in project-root))
(args (split-string
(string-trim
(concat (if all-files "-uu")
(unless recursive "--maxdepth 1")
"--null --line-buffered --color=always --max-columns=500 --no-heading --line-number"
" --hidden -g !.git "
(mapconcat #'shell-quote-argument args " ")))
" "))
(prompt (or prompt
(format "rg [%s]: "
(cond ((equal directory default-directory)
"./")
((equal directory project-root)
(projectile-project-name))
((file-relative-name directory project-root))))))
(query (or query
(when (doom-region-active-p)
(replace-regexp-in-string
"[! |]" (lambda (substr)
(cond ((and (string= substr " ")
(not (featurep! +fuzzy)))
" ")
((string= substr "|")
"\\\\\\\\|")
((concat "\\\\" substr))))
(rxt-quote-pcre (doom-thing-at-point-or-region))))))
(ripgrep-command (mapconcat #'identity `("rg" ,@args "." "-e ARG OPTS" ) " ")))
(consult--grep prompt ripgrep-command directory query)))
;;;###autoload
(defun +selectrum/project-search (&optional arg initial-query directory)
"Peforms a live project search from the project root using ripgrep.
If ARG (universal argument), include all files, even hidden or compressed ones,
in the search."
(interactive "P")
(+selectrum-file-search :query initial-query :in directory :all-files arg))
;;;###autoload
(defun +selectrum/project-search-from-cwd (&optional arg initial-query)
"Performs a live project search from the current directory.
If ARG (universal argument), include all files, even hidden or compressed ones."
(interactive "P")
(+selectrum/project-search arg initial-query default-directory))
;;;###autoload
(defun +selectrum/search-symbol-at-point ()
(interactive)
(consult-line (thing-at-point 'symbol)))
;;;###autoload
(defun +selectrum/backward-updir ()
"Delete char before or go up directory for file cagetory vertico buffers."
(interactive)
(let ((metadata (completion-metadata (minibuffer-contents)
minibuffer-completion-table
minibuffer-completion-predicate)))
(if (and (eq (char-before) ?/)
(eq (completion-metadata-get metadata 'category) 'file))
(let ((new-path (minibuffer-contents)))
(delete-region (minibuffer-prompt-end) (point-max))
(insert (abbreviate-file-name
(file-name-directory
(directory-file-name
(expand-file-name new-path))))))
(call-interactively 'backward-delete-char))))
;;;###autoload
(defun +selectrum/embark-export-write ()
"Export the current vertico results to a writable buffer if possible.
Supports exporting consult-grep to wgrep, file to wdeired, and consult-location to occur-edit"
(interactive)
(require 'wgrep)
(pcase-let ((`(,type . ,candidates)
(run-hook-with-args-until-success 'embark-candidate-collectors)))
(pcase type
('consult-grep (let ((embark-after-export-hook #'wgrep-change-to-wgrep-mode))
(embark-export)))
('file (let ((embark-after-export-hook #'wdired-change-to-wdired-mode))
(embark-export)))
('consult-location (let ((embark-after-export-hook #'occur-edit-mode))
(embark-export)))
(x (user-error "embark category %S doesn't support writable export" x)))))
;;;###autoload
(defun +selectrum/embark-preview ()
"Previews candidate in vertico buffer, unless it's a consult command"
(interactive)
(unless (bound-and-true-p consult--preview-function)
(save-selected-window
(let ((embark-quit-after-action nil))
(embark-default-action)))))
;;;###autoload
(defun +selectrum/next-candidate-preview ()
"Move to next candidate and preivew it"
(interactive)
(vertico-next)
(+selectrum/embark-preview))
;;;###autoload
(defun +selectrum/previous-candidate-preview ()
"Move to previous candidate and preview it"
(interactive)
(vertico-previous)
(+selectrum/embark-preview))

View file

@ -0,0 +1,53 @@
;;; completion/vertico/autoload/workspaces.el -*- lexical-binding: t; -*-
;;;###if (featurep! :ui workspaces)
;;;###autoload
(defun +selectrum--workspace-nth-source (n)
"Generate a consult buffer source for buffers in the NTH workspace"
(cond ((numberp n)
`(:name ,(nth n (+workspace-list-names))
:hidden ,(not (string= (+workspace-current-name) (nth n (+workspace-list-names))))
:narrow ,(string-to-char (number-to-string (1+ n)))
:category buffer
:state ,#'consult--buffer-state
:items ,(lambda () (mapcar #'buffer-name (+workspace-buffer-list (nth n (+workspace-list)))))))
((eq n 'final)
`(:name ,(car (last (+workspace-list-names)))
:hidden t
:narrow ?0
:category buffer
:state ,#'consult--buffer-state
:items ,(lambda () (mapcar #'buffer-name (+workspace-buffer-list (car (last (+workspace-list))))))))
(t
(user-error "invalid workspace source %s" n))))
;;;###autoload
(defun +selectrum--workspace-generate-sources ()
"Generate list of consult buffer sources for all workspaces"
(mapcar #'+selectrum--workspace-nth-source '(0 1 2 3 4 5 6 7 8 final)))
(autoload 'consult--multi "consult")
;;;###autoload
(defun +selectrum/switch-workspace-buffer ()
"Switch to another buffer in the same workspace.
Use consult narrowing with another workspace number to open a buffer from that workspace
BUG but it opens it in the current workspace (ivy also does this, but who cares)"
(interactive)
(when-let (buffer (consult--multi (+selectrum--workspace-generate-sources)
:require-match
(confirm-nonexistent-file-or-buffer)
:prompt (format "Switch to buffer (%s): "
(+workspace-current-name)
:history 'consult--buffer-history
:sort nil)))
;; When the buffer does not belong to a source,
;; create a new buffer with the name.
(unless (cdr buffer)
(funcall consult--buffer-display (car buffer)))))
;;;###autoload
(defun +selectrum-embark-open-in-new-workspace (x)
"Open X (a file) in a new workspace."
(+workspace/new)
(find-file x))

View file

@ -0,0 +1,163 @@
;;; completion/vertico/config.el -*- lexical-binding: t; -*-
(use-package! vertico
:hook (doom-first-input . vertico-mode)
:init
(setq vertico-resize nil
vertico-count 17
vertico-cycle t)
(add-hook 'vertico-mode-hook (lambda ()
(setq completion-in-region-function
(if vertico-mode
#'consult-completion-in-region
#'completion--in-region))))
:config
(map! :map vertico-map
[backspace] #'+selectrum/backward-updir))
(use-package! orderless
:demand t
:config
(defun +selectrum-orderless-dispatch (pattern _index _total)
(cond
;; Ensure that $ works with Consult commands, which add disambiguation suffixes
((string-suffix-p "$" pattern) `(orderless-regexp . ,(concat (substring pattern 0 -1) "[\x100000-\x10FFFD]*$")))
;; Ignore single !
((string= "!" pattern) `(orderless-literal . ""))
;; Without literal
((string-prefix-p "!" pattern) `(orderless-without-literal . ,(substring pattern 1)))
;; Initialism matching
((string-prefix-p "`" pattern) `(orderless-initialism . ,(substring pattern 1)))
((string-suffix-p "`" pattern) `(orderless-initialism . ,(substring pattern 0 -1)))
;; Literal matching
((string-prefix-p "=" pattern) `(orderless-literal . ,(substring pattern 1)))
((string-suffix-p "=" pattern) `(orderless-literal . ,(substring pattern 0 -1)))
;; Flex matching
((string-prefix-p "~" pattern) `(orderless-flex . ,(substring pattern 1)))
((string-suffix-p "~" pattern) `(orderless-flex . ,(substring pattern 0 -1)))))
(setq completion-styles '(orderless)
completion-category-defaults nil
;; note that despite override in the name orderless can still be used in find-file etc.
completion-category-overrides '((file (styles . (orderless partial-completion))))
orderless-style-dispatchers '(+selectrum-orderless-dispatch)
orderless-component-separator "[ &]")
;; otherwise find-file gets different highlighting than other commands
(set-face-attribute 'completions-first-difference nil :inherit nil))
(use-package! consult
:defer t
:init
(fset 'multi-occur #'consult-multi-occur)
(define-key!
[remap apropos] #'consult-apropos
[remap bookmark-jump] #'consult-bookmark
[remap evil-show-marks] #'consult-mark
[remap goto-line] #'consult-goto-line
[remap imenu] #'consult-imenu
[remap locate] #'consult-locate
[remap load-theme] #'consult-theme
[remap man] #'consult-man
[remap recentf-open-files] #'consult-recent-file
[remap switch-to-buffer] #'consult-buffer
[remap switch-to-buffer-other-window] #'consult-buffer-other-window
[remap switch-to-buffer-other-frame] #'consult-buffer-other-frame
[remap yank-pop] #'consult-yank-pop
[remap persp-switch-to-buffer] #'+selectrum/switch-workspace-buffer)
(advice-add #'completing-read-multiple :override #'consult-completing-read-multiple)
:config
(recentf-mode)
(setq consult-project-root-function #'doom-project-root
consult-narrow-key "<"
consult-line-numbers-widen t)
(consult-customize
consult-ripgrep consult-git-grep consult-grep
consult-bookmark consult-recent-file
+default/search-project +default/search-project-for-symbol-at-point
+default/search-other-project +selectrum/search-symbol-at-point
+default/search-cwd +default/search-other-cwd
+default/search-notes-for-symbol-at-point
consult--source-file consult--source-project-file consult--source-bookmark
:preview-key (list (kbd "C-SPC") (kbd "C-M-j") (kbd "C-M-k")))
(consult-customize
consult-theme
:preview-key
(list (kbd "C-SPC") (kbd "C-M-j") (kbd "C-M-k")
:debounce 0.5 'any)))
(use-package! consult-flycheck
:when (featurep! :checkers syntax)
:after (consult flycheck))
(use-package! embark
:init
(setq embark-action-indicator
(lambda (map _target)
(which-key--show-keymap "Embark" map nil nil 'no-paging)
#'which-key--hide-popup-ignore-command)
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" #'+selectrum/embark-export-write)
(define-key!
[remap describe-bindings] #'embark-bindings)
(defun +selectrum--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,
;; so we don't get a false positive match.
(let ((pos (or (cl-position
'embark-target-file-at-point
embark-target-finders)
(length embark-target-finders))))
(cl-callf2
cons
'+selectrum--embark-target-package!
(nthcdr pos embark-target-finders)))
(map!
:map embark-file-map
:desc "Open target with sudo" "s" #'doom/sudo-find-file
:desc "Open in new workspace" "TAB" #'+selectrum-embark-open-in-new-workspace)
(setq embark-package-map (make-sparse-keymap))
(map! :map embark-package-map
"h" #'doom/help-packages
"b" #'doom/bump-package
"c" #'doom/help-package-config
"u" #'doom/help-package-homepage))
(use-package! marginalia
:hook (doom-first-input . marginalia-mode)
:init
(when (featurep! +icons)
(add-hook 'marginalia-mode-hook
(lambda () (all-the-icons-completion-mode (if marginalia-mode 1 -1)))))
(map! :map minibuffer-local-map
:desc "Cycle marginalia views"
"M-A" #'marginalia-cycle)
:config
(nconc marginalia-command-categories
'((persp-switch-to-buffer . buffer)
(projectile-find-file . project-file)
(doom/describe-active-minor-mode . minor-mode)
(flycheck-error-list-set-filter . builtin))))
(use-package! embark-consult
:after (embark consult)
:demand t
:hook
(embark-collect-mode . consult-preview-at-point-mode))
(use-package! wgrep
:commands wgrep-change-to-wgrep-mode
:config (setq wgrep-auto-save-buffer t))

View file

@ -0,0 +1,25 @@
;; -*- no-byte-compile: t; -*-
;;; completion/vertico/packages.el
(package! vertico
:recipe (:host github :repo "minad/vertico"
:files ("*.el" "extensions/*.el"))
:pin "9f6cd5d431ec6d288676af80e932d928346a1b36")
(package! orderless :pin "2646dad28c0819fbe9ee521d39efb9ae40e03982")
(package! consult :pin "f17db9520ddd612dc837f4112b6bcbb172acef85")
(when (featurep! :checkers syntax)
(package! consult-flycheck :pin "92b259e6a8ebe6439f67d3d7ffa44b7e64b76478"))
(package! embark :pin "acbe1cba548832d295449da348719f69b9685c6f")
(package! embark-consult :pin "acbe1cba548832d295449da348719f69b9685c6f")
(package! marginalia :pin "3bf0a4db55f6267467f0a08715f4776509a3b503")
(package! wgrep :pin "f9687c28bbc2e84f87a479b6ce04407bb97cfb23")
(when (featurep! +icons)
(package! all-the-icons-completion
:recipe (:host github :repo "iyefrat/all-the-icons-completion")
:pin "975345f1b618fd316729c3cae6d11b96db530fd4"))