feat(selectrum): Add config from Townk's private config

Co-authored-by: Townk <thiago@rapinialves.com>
This commit is contained in:
Edmund Miller 2021-02-16 16:46:35 -06:00 committed by Itai Y. Efrat
parent a0ff8d42c1
commit 42b3184eae
2 changed files with 154 additions and 45 deletions

View file

@ -2,22 +2,55 @@
(use-package! selectrum
:hook (doom-first-input . selectrum-mode)
:config
(setq selectrum-extend-current-candidate-highlight t
:init
(setq selectrum-display-action nil
selectrum-num-candidates-displayed 15
selectrum-extend-current-candidate-highlight t
selectrum-fix-minibuffer-height t)
(unless (featurep! +orderless)
(setq completion-styles '(substring partial-completion))))
(when (featurep! +orderless)
(when (featurep! +prescient)
(use-package! selectrum-prescient
:after selectrum
:hook ((selectrum-mode . selectrum-prescient-mode)
(selectrum-mode . prescient-persist-mode))))
(setq completion-styles '(substring partial-completion)
selectrum-refine-candidates-function #'orderless-filter
selectrum-highlight-candidates-function #'orderless-highlight-matches))
(when (featurep! +prescient)
(use-package! selectrum-prescient
:after selectrum
:hook ((selectrum-mode . selectrum-prescient-mode)
(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)))
:config
(defadvice! +selectrum-refresh-on-cycle (&rest _)
:after 'marginalia-cycle
(when (bound-and-true-p selectrum-mode) (selectrum-exhibit)))
(map!
:g "C-s-r" #'selectrum-repeat
(:map selectrum-minibuffer-map
:geni "M-RET" #'selectrum-submit-exact-input
:geni "C-j" #'selectrum-next-candidate
:geni "C-S-j" #'selectrum-next-page
:geni "C-s-j" #'selectrum-goto-end
:geni "C-k" #'selectrum-previous-candidate
:geni "C-S-k" #'selectrum-previous-page
:geni "C-s-k" #'selectrum-goto-beginning)))
(use-package! orderless
:when (featurep! +orderless)
:defer t
:init
(setq orderless-component-separator "[ &]"
orderless-matching-styles '(orderless-prefixes
orderless-initialism
orderless-regexp))
:config
(setq completion-styles '(orderless)))
(setq completion-styles '(orderless))
(setq orderless-skip-highlighting (lambda () selectrum-active-p))
(setq selectrum-highlight-candidates-function #'orderless-highlight-matches))
(use-package! consult
:defer t
@ -36,7 +69,12 @@
[remap load-theme] #'consult-theme
[remap recentf-open-files] #'consult-recent-file)
:config
(setq consult-project-root-function #'projectile-project-root))
(setq consult-project-root-function #'doom-project-root)
(setq completion-in-region-function #'consult-completion-in-region)
(setq consult-narrow-key "<")
(setq consult-line-numbers-widen t)
(setq consult-async-input-debounce 0.5)
(setq consult-async-input-throttle 0.8))
(use-package! consult-flycheck
:when (featurep! :checkers syntax)
@ -45,12 +83,22 @@
(use-package! embark
:defer t
:init
(define-key!
"C-S-a" #'embark-act)
;; TODO need to figure out what keybindings to put here
(define-key! selectrum-minibuffer-map
(map!
:g "C-s-e" #'embark-act
(:map minibuffer-local-completion-map
"C-c C-o" #'embark-export
"C-c C-c" #'embark-act-noexit))
"C-c C-c" #'embark-act-noexit)
(:map embark-file-map
:desc "Open Dired on target" :g "j" #'ffap-dired
:desc "Open target with sudo" :g "s" #'sudo-edit
:desc "Open target with vlf" :g "l" #'vlf)
(:map embark-file-map
:desc "Cycle marginalia views" :g "A" #'marginalia-cycle))
(setq embark-action-indicator
(lambda (map)
(which-key--show-keymap "Embark" map nil nil 'no-paging)
#'which-key--hide-popup-ignore-command)
embark-become-indicator embark-action-indicator))
(use-package! marginalia
:after selectrum