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-05-01 14:38:54 +03:00
|
|
|
(when (featurep! +prescient)
|
2021-02-16 19:37:40 -06:00
|
|
|
(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)))
|
2021-05-01 13:58:02 +03:00
|
|
|
|
|
|
|
(defun +selectrum/backward-updir ()
|
|
|
|
"Delete char before or go up directory for file cagetory selectrum buffers."
|
|
|
|
(interactive)
|
|
|
|
(if (and (eq (char-before) ?/)
|
|
|
|
(eq (selectrum--get-meta '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)))
|
|
|
|
|
2021-04-29 12:32:04 +03:00
|
|
|
(map! :map selectrum-minibuffer-map
|
2021-05-29 16:02:02 +03:00
|
|
|
[backspace] #'+selectrum/backward-updir))
|
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-01-16 20:21:50 +08:00
|
|
|
(use-package! orderless
|
2021-05-01 14:38:54 +03:00
|
|
|
:when (not (featurep! +prescient))
|
2021-05-04 16:16:36 +03:00
|
|
|
:demand t
|
2021-01-16 20:21:50 +08:00
|
|
|
:config
|
2021-05-04 16:16:36 +03:00
|
|
|
(defun +selectrum-orderless-dispatch (pattern _index _total)
|
|
|
|
(cond
|
2021-05-16 03:18:13 +03:00
|
|
|
;; Ensure that $ works with Consult commands, which add disambiguation suffixes
|
2021-05-04 16:16:36 +03:00
|
|
|
((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)))
|
2021-05-16 03:18:13 +03:00
|
|
|
;; 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)))
|
2021-05-04 16:16:36 +03:00
|
|
|
((string-suffix-p "=" pattern) `(orderless-literal . ,(substring pattern 0 -1)))
|
|
|
|
;; Flex matching
|
2021-05-16 03:18:13 +03:00
|
|
|
((string-prefix-p "~" pattern) `(orderless-flex . ,(substring pattern 1)))
|
2021-05-04 16:16:36 +03:00
|
|
|
((string-suffix-p "~" pattern) `(orderless-flex . ,(substring pattern 0 -1)))))
|
2021-05-01 14:44:29 +03:00
|
|
|
(setq completion-styles '(orderless)
|
2021-05-04 16:16:36 +03:00
|
|
|
completion-category-defaults nil
|
|
|
|
;; note that despite override in the name orderless can still be used in find-file etc.
|
2021-05-17 13:42:45 +03:00
|
|
|
completion-category-overrides '((file (styles . (partial-completion))))
|
2021-05-04 16:16:36 +03:00
|
|
|
orderless-style-dispatchers '(+selectrum-orderless-dispatch)
|
|
|
|
orderless-component-separator "[ &]"
|
2021-05-01 14:44:29 +03:00
|
|
|
selectrum-refine-candidates-function #'orderless-filter
|
2021-05-04 16:16:36 +03:00
|
|
|
selectrum-highlight-candidates-function #'orderless-highlight-matches))
|
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
|
2021-05-21 16:38:54 +03:00
|
|
|
[remap persp-switch-to-buffer] #'+selectrum/switch-workspace-buffer)
|
2021-05-01 12:16:06 +02:00
|
|
|
(setq completion-in-region-function #'consult-completion-in-region)
|
2021-01-16 20:21:50 +08:00
|
|
|
:config
|
2021-04-25 21:08:13 +03:00
|
|
|
(recentf-mode)
|
2021-05-16 02:29:48 +03:00
|
|
|
(setq consult-project-root-function #'doom-project-root
|
|
|
|
completion-in-region-function #'consult-completion-in-region
|
|
|
|
consult-narrow-key "<"
|
|
|
|
consult-line-numbers-widen t
|
|
|
|
consult-async-input-debounce 0.5
|
|
|
|
consult-async-input-throttle 0.8)
|
2021-05-26 02:33:13 +03:00
|
|
|
(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"))))
|
2021-01-16 03:04:18 +08:00
|
|
|
|
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
|
|
|
|
:init
|
2021-02-16 16:46:35 -06:00
|
|
|
(setq embark-action-indicator
|
2021-05-17 00:14:55 +03:00
|
|
|
(lambda (map _target)
|
2021-02-16 16:46:35 -06:00
|
|
|
(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)
|
2021-05-29 16:02:02 +03:00
|
|
|
(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)
|
2021-04-27 02:49:47 +03:00
|
|
|
:config
|
2021-04-29 12:32:04 +03:00
|
|
|
(map!
|
|
|
|
:map embark-file-map
|
|
|
|
:desc "Open Dired on target" "j" #'ffap-dired
|
2021-05-26 01:38:18 +03:00
|
|
|
:desc "Open target with sudo" "s" #'doom/sudo-find-file
|
2021-05-23 16:00:39 +03:00
|
|
|
:desc "Open target with vlf" "l" #'vlf)
|
|
|
|
(set-popup-rule! "^\\*Embark Export" :size 0.35 :ttl 0 :quit nil)
|
|
|
|
(set-popup-rule! "^\\*Embark Collect" :size 0.35 :ttl 0 :quit nil))
|
2021-01-16 03:04:18 +08:00
|
|
|
|
|
|
|
(use-package! marginalia
|
|
|
|
:hook (doom-first-input . marginalia-mode)
|
2021-05-29 16:02:02 +03:00
|
|
|
:init
|
|
|
|
(map! :map minibuffer-local-map
|
|
|
|
:desc "Cycle marginalia views"
|
|
|
|
"M-A" #'marginalia-cycle)
|
2021-04-11 00:48:39 +03:00
|
|
|
: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)
|
2021-05-07 21:27:14 +03:00
|
|
|
:demand t
|
2021-01-16 03:04:18 +08:00
|
|
|
:hook
|
2021-05-22 23:22:17 +03:00
|
|
|
(embark-collect-mode . consult-preview-at-point-mode))
|
2021-05-07 11:40:55 -05:00
|
|
|
|
|
|
|
(use-package! wgrep
|
|
|
|
:commands wgrep-change-to-wgrep-mode
|
|
|
|
:config (setq wgrep-auto-save-buffer t))
|