Add commands to compleseus layer (locate, yasnippet, search from) (#15078)

* Add commands to compleseus+fasd layer (locate,yasnippet,search-from)

* Add metadata classifier (for embark) to fasd-layer

Embark uses metadata of the target under point to determine actions. If the
target lacks a metadata classifier then the [embark
documentation](https://github.com/oantolin/embark#acting-on-targets) recommends
to [add them using the marginalia package](https://github.com/minad/marginalia#adding-custom-annotators-or-classifiers).

This PR adds the file classifier to results for fasd searches.
This commit is contained in:
Daniel Nicolai 2021-11-02 22:50:32 +01:00 committed by GitHub
parent 7ac303922e
commit d5b6df3584
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 38 additions and 11 deletions

View File

@ -1,4 +1,4 @@
#+TITLE: compleseus layer
#+TITLE: Compleseus layer
#+TAGS: completion|layer
@ -44,7 +44,7 @@ like below to use =selectrum= as opposed to the default of =vertico=:
* Key bindings
| Key binding | Description |
|-------------+---------------|
| ~M-o~ | embark-action |
| ~C-r~ | history |
| Key binding | Description |
|-------------+-------------------|
| ~M-o~ | embark-action |
| ~C-r~ | history |

View File

@ -96,6 +96,15 @@
(interactive)
(spacemacs/compleseus-search nil (projectile-project-root)))
(defun spacemacs/compleseus-search-from (input)
"Embark action to start ripgrep search from candidate's directory."
(interactive "s")
(message "The first input %s." input)
(let ((dir (if (file-directory-p input)
input
(file-name-directory input))))
(consult-ripgrep dir)))
(defun spacemacs/compleseus-find-file ()
"This solves the problem:
Binding a key to: `find-file' calls: `ido-find-file'"
@ -118,13 +127,13 @@ Binding a key to: `find-file' calls: `ido-find-file'"
(embark-dwim)))))
(defun spacemacs/next-candidate-preview (&optional n)
"Go forward N candidates and preivew"
"Go forward N candidates and preview"
(interactive)
(vertico-next (or n 1))
(spacemacs/embark-preview))
(defun spacemacs/previous-candidate-preview (&optional n)
"Go backward N candidates and preivew"
"Go backward N candidates and preview"
(interactive)
(selec-previous (or n 1))
(spacemacs/embark-preview))
@ -132,13 +141,13 @@ Binding a key to: `find-file' calls: `ido-find-file'"
;; selectrum
(defun spacemacs/selectrum-next-candidate-preview (&optional n)
"Go forward N candidates and preivew"
"Go forward N candidates and preview"
(interactive)
(selectrum-next-candidate (or n 1))
(spacemacs/embark-preview))
(defun spacemacs/selectrum-previous-candidate-preview (&optional n)
"Go backward N candidates and preivew"
"Go backward N candidates and preview"
(interactive)
(selectrum-previous-candidate (or n 1))
(spacemacs/embark-preview))

View File

@ -26,6 +26,9 @@
marginalia
(compleseus-spacemacs-help :location local)
consult
;; remove recipe when available on Melpa (should be soon)
(consult-yasnippet :location (recipe :fetcher github
:repo "mohkale/consult-yasnippet"))
embark
embark-consult
orderless
@ -135,6 +138,7 @@
"bB" #'consult-buffer
"fb" #'consult-bookmark
"ff" #'spacemacs/compleseus-find-file
"fL" #'consult-locate
"fr" #'consult-recent-file
"hda" #'consult-apropos
"jm" #'consult-mark
@ -214,6 +218,13 @@
;; (setq consult-project-root-function (lambda () (locate-dominating-file "." ".git")))
))
(defun compleseus/init-consult-yasnippet ()
(use-package consult-yasnippet
:defer t
:init
(spacemacs/set-leader-keys
"is" 'consult-yasnippet)))
(defun compleseus/init-embark ()
(use-package embark
:bind
@ -227,6 +238,7 @@
(setq prefix-help-command #'embark-prefix-help-command)
:config
(define-key embark-file-map "s" 'spacemacs/compleseus-search-from)
;; Hide the mode line of the Embark live/completions buffers
;; (add-to-list 'display-buffer-alist
;; '("\\`\\*Embark Collect \\(Live\\|Completions\\)\\*"
@ -298,7 +310,9 @@
(define-key vertico-map (kbd "C-k") #'vertico-previous)
(define-key vertico-map (kbd "C-M-k") #'spacemacs/previous-candidate-preview)
(define-key vertico-map (kbd "C-S-k") #'vertico-previous-group)
(define-key vertico-map (kbd "C-r") 'consult-history)))
(define-key vertico-map (kbd "C-r") 'consult-history)
(define-key vertico-map (kbd "C-h") 'backward-kill-word)
(define-key vertico-map "?" #'minibuffer-completion-help)))
(defun compleseus/init-vertico-repeat ()
(use-package vertico-repeat

View File

@ -53,7 +53,11 @@
("s" ivy-search-from-action "search-from"))))
;; we will fall back to using the default completing-read function, which is helm once helm is loaded.
(setq fasd-completing-read-function 'nil))))
(setq fasd-completing-read-function 'nil))
:config
(with-eval-after-load 'marginalia
(add-to-list 'marginalia-prompt-categories '("\\<fasd\\>" . file)))))
(defun fasd/init-helm-fasd ()
"initializes fasd-emacs and adds a key binding to `SPC f z'"