2021-01-16 03:04:18 +08:00
|
|
|
;;; completion/selectrum/config.el -*- lexical-binding: t; -*-
|
|
|
|
|
|
|
|
(use-package! selectrum
|
2021-01-16 20:21:50 +08:00
|
|
|
:hook (doom-first-input . selectrum-mode)
|
2021-02-16 16:46:35 -06:00
|
|
|
:init
|
|
|
|
(setq selectrum-display-action nil
|
|
|
|
selectrum-num-candidates-displayed 15
|
2021-02-21 14:40:26 -06:00
|
|
|
selectrum-extend-current-candidate-highlight t)
|
2021-02-16 19:37:40 -06:00
|
|
|
(unless (featurep! +orderless)
|
|
|
|
(setq completion-styles '(substring partial-completion)))
|
2021-02-16 16:46:35 -06:00
|
|
|
:config
|
2021-03-07 11:41:33 -06:00
|
|
|
(setq selectrum-fix-vertical-window-height 17
|
|
|
|
selectrum-max-window-height 17)
|
2021-02-16 16:46:35 -06:00
|
|
|
(defadvice! +selectrum-refresh-on-cycle (&rest _)
|
|
|
|
:after 'marginalia-cycle
|
2021-04-29 12:32:04 +03:00
|
|
|
(when (bound-and-true-p selectrum-mode) (selectrum-exhibit)))
|
|
|
|
(map! :map selectrum-minibuffer-map
|
|
|
|
"C-o" #'embark-act
|
|
|
|
"C-c C-o" #'embark-export))
|
2021-01-16 03:04:18 +08:00
|
|
|
|
2021-02-16 19:28:13 -06:00
|
|
|
(use-package! selectrum-prescient
|
|
|
|
:when (featurep! +prescient)
|
|
|
|
:hook (selectrum-mode . selectrum-prescient-mode)
|
|
|
|
:hook (selectrum-mode . prescient-persist-mode)
|
|
|
|
:config
|
|
|
|
(setq selectrum-preprocess-candidates-function #'selectrum-prescient--preprocess)
|
|
|
|
(add-hook 'selectrum-candidate-selected-hook #'selectrum-prescient--remember)
|
|
|
|
(add-hook 'selectrum-candidate-inserted-hook #'selectrum-prescient--remember))
|
|
|
|
|
2021-04-01 20:17:30 -04:00
|
|
|
(defun flex-if-twiddle (pattern _index _total)
|
|
|
|
(when (string-suffix-p "~" pattern)
|
|
|
|
`(orderless-flex . ,(substring pattern 0 -1))))
|
|
|
|
|
|
|
|
(defun first-initialism (pattern index _total)
|
|
|
|
(if (= index 0) 'orderless-initialism))
|
|
|
|
|
|
|
|
(defun without-if-bang (pattern _index _total)
|
|
|
|
"Define a '!not' exclusion prefix for literal strings."
|
|
|
|
(when (string-prefix-p "!" pattern)
|
|
|
|
`(orderless-without-literal . ,(substring pattern 1))))
|
|
|
|
|
2021-01-16 20:21:50 +08:00
|
|
|
(use-package! orderless
|
|
|
|
:when (featurep! +orderless)
|
2021-04-25 18:32:47 +03:00
|
|
|
:after selectrum
|
2021-02-16 16:46:35 -06:00
|
|
|
:init
|
|
|
|
(setq orderless-component-separator "[ &]"
|
|
|
|
orderless-matching-styles '(orderless-prefixes
|
|
|
|
orderless-initialism
|
|
|
|
orderless-regexp))
|
2021-01-16 20:21:50 +08:00
|
|
|
:config
|
2021-02-16 16:46:35 -06:00
|
|
|
(setq completion-styles '(orderless))
|
2021-04-16 10:36:03 +01:00
|
|
|
(setq orderless-skip-highlighting (lambda () selectrum-is-active))
|
2021-04-25 18:32:47 +03:00
|
|
|
(setq selectrum-refine-candidates-function #'orderless-filter)
|
2021-04-01 20:17:30 -04:00
|
|
|
(setq selectrum-highlight-candidates-function #'orderless-highlight-matches)
|
|
|
|
(setq orderless-matching-styles '(orderless-regexp)
|
|
|
|
orderless-style-dispatchers '(flex-if-twiddle
|
|
|
|
without-if-bang)))
|
2021-01-16 20:21:50 +08:00
|
|
|
|
2021-01-16 03:04:18 +08:00
|
|
|
(use-package! consult
|
|
|
|
:defer t
|
|
|
|
:init
|
2021-01-16 20:21:50 +08:00
|
|
|
(fset 'multi-occur #'consult-multi-occur)
|
2021-01-16 03:04:18 +08:00
|
|
|
(define-key!
|
2021-02-18 22:06:00 -06:00
|
|
|
[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
|
2021-01-16 03:04:18 +08:00
|
|
|
[remap switch-to-buffer-other-window] #'consult-buffer-other-window
|
2021-02-18 22:06:00 -06:00
|
|
|
[remap switch-to-buffer-other-frame] #'consult-buffer-other-frame
|
2021-04-29 12:32:04 +03:00
|
|
|
[remap yank-pop] #'consult-yank-pop
|
|
|
|
[remap describe-bindings] #'embark-bindings)
|
2021-01-16 20:21:50 +08:00
|
|
|
:config
|
2021-04-25 21:08:13 +03:00
|
|
|
(recentf-mode)
|
2021-02-16 16:46:35 -06:00
|
|
|
(setq consult-project-root-function #'doom-project-root)
|
|
|
|
(setq completion-in-region-function #'consult-completion-in-region)
|
|
|
|
(setq consult-narrow-key "<")
|
2021-04-30 00:19:38 +03:00
|
|
|
(setf (alist-get #'consult-bookmark consult-config) (list :preview-key (kbd "C-SPC")))
|
|
|
|
(setf (alist-get #'consult-recent-file consult-config) (list :preview-key (kbd "C-SPC")))
|
|
|
|
(setf (alist-get #'consult--grep consult-config) (list :preview-key (kbd "C-SPC")))
|
2021-02-16 16:46:35 -06:00
|
|
|
(setq consult-line-numbers-widen t)
|
|
|
|
(setq consult-async-input-debounce 0.5)
|
|
|
|
(setq consult-async-input-throttle 0.8))
|
2021-01-16 03:04:18 +08:00
|
|
|
|
2021-04-27 22:39:36 +02:00
|
|
|
(use-package! consult-xref
|
|
|
|
:defer t
|
|
|
|
:init
|
|
|
|
(setq xref-show-xrefs-function #'consult-xref
|
|
|
|
xref-show-definitions-function #'consult-xref))
|
|
|
|
|
2021-01-16 20:21:50 +08:00
|
|
|
(use-package! consult-flycheck
|
|
|
|
:when (featurep! :checkers syntax)
|
|
|
|
:after (consult flycheck))
|
2021-01-16 03:04:18 +08:00
|
|
|
|
|
|
|
(use-package! embark
|
2021-01-16 20:29:16 +08:00
|
|
|
:defer t
|
2021-01-16 03:04:18 +08:00
|
|
|
:init
|
2021-02-16 16:46:35 -06:00
|
|
|
(setq embark-action-indicator
|
|
|
|
(lambda (map)
|
|
|
|
(which-key--show-keymap "Embark" map nil nil 'no-paging)
|
|
|
|
#'which-key--hide-popup-ignore-command)
|
2021-04-27 02:49:47 +03:00
|
|
|
embark-become-indicator embark-action-indicator)
|
|
|
|
:config
|
2021-04-29 12:32:04 +03:00
|
|
|
(map!
|
|
|
|
:map embark-file-map
|
|
|
|
:desc "Open Dired on target" "j" #'ffap-dired
|
|
|
|
:desc "Open target with sudo" "s" #'sudo-edit
|
|
|
|
:desc "Open target with vlf" "l" #'vlf
|
|
|
|
:map embark-file-map
|
2021-04-30 00:19:38 +03:00
|
|
|
:desc "Cycle marginalia views" "A" #'marginalia-cycle))
|
2021-01-16 03:04:18 +08:00
|
|
|
|
|
|
|
(use-package! marginalia
|
|
|
|
:hook (doom-first-input . marginalia-mode)
|
|
|
|
:init
|
2021-04-11 00:48:39 +03:00
|
|
|
(setq-default marginalia-annotators '(marginalia-annotators-heavy))
|
|
|
|
:config
|
|
|
|
(add-to-list 'marginalia-command-categories '(persp-switch-to-buffer . buffer)))
|
2021-01-16 03:04:18 +08:00
|
|
|
|
|
|
|
(use-package! embark-consult
|
|
|
|
:after (embark consult)
|
|
|
|
:hook
|
|
|
|
(embark-collect-mode . embark-consult-preview-minor-mode))
|