blob: 6428a9771546104ebf2036b0c2063f9041f9bd62 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
|
;;; selection-framework --- Search/Narrowing and Related Functionality -*- lexical-binding: t; -*-
;; author: Craig Jennings <c@cjennings.net>
;;; Commentary:
;;; Code:
;; ---------------------------------- Company ----------------------------------
;; Company is a modular in-buffer tool-tip-style completion front-end framework.
(use-package company
:defer .5
:hook
((text-mode . company-mode)
(prog-mode . company-mode)
(lisp-interaction-mode . company-mode))
:custom
;; search other buffers =with the same mode= for completion
(company-dabbrev-other-buffers t)
(company-dabbrev-code-other-buffers t)
;; M-<num> to select an option according to its number.
(company-show-numbers t)
;; 2 letters required for completion to activate.
(company-minimum-prefix-length 3)
;; don't downcase completions by default.
(company-dabbrev-downcase nil)
;; provide proper casing even if I don't.
(company-dabbrev-ignore-case t)
;; company completion wait
(company-idle-delay 0.2)
;; use vscode icons in the margin
(setq company-format-margin-function #'company-vscode-light-icons-margin)
;; no company-mode in shell & eshell
(company-global-modes '(not eshell-mode shell-mode)))
(with-eval-after-load 'company
(define-key company-active-map
(kbd "TAB")
#'company-complete-common-or-cycle)
(define-key company-active-map
(kbd "<backtab>")
(lambda ()
(interactive)
(company-complete-common-or-cycle -1))))
;; ---------------------------------- Counsel ----------------------------------
;; part of the counsel/ivy/swiper trio. ivy-enhanced versions of Emacs commands.
(use-package counsel
:defer .5
:bind
("C-c U" . counsel-unicode-char))
;; ------------------------------------ Ivy ------------------------------------
;; A generic completion mechanism for Emacs. https://github.com/abo-abo/swiper#ivy
(use-package ivy
:defer .5
:bind (("C-c u" . ivy-resume))
(:map ivy-occur-grep-mode-map
("n" . ivy-occur-next-line)
("p" . ivy-occur-previous-line)
("b" . backward-char)
("f" . forward-char)
("v" . ivy-occur-press)
("RET" . ivy-occur-press))
:config
(setq ivy-action-wrap t) ;; wrap next and previous actions
(setq ivy-count-format "%d/%d ") ;; show index as well as count
(setq ivy-extra-directories nil) ;; don't show ./ and ../ in lists
(setq ivy-height 13) ;; 13 lines high
(setq ivy--regex-ignore-order t) ;; ignore word order
(setq ivy-use-selectable-prompt t) ;; prompt becomes selectable
(setq ivy-use-virtual-buffers t) ;; ivy-switch-buffer shows recently killed buffers
(setq ivy-virtual-abbreviate 'full) ;; show the full virtual file path
(setq ivy-wrap t) ;; wrap list when finished to start and vice-versa
(ivy-mode)
;; modify default search behaviour of ivy
(setq ivy-re-builders-alist
'((t . ivy--regex-plus))))
;; ALL THE ICONS IVY
;; Shows icons while using Ivy and Counsel
;; https://github.com/asok/all-the-icons-ivy
(use-package all-the-icons-ivy
:defer .5
:after ivy
:init (add-hook 'after-init-hook 'all-the-icons-ivy-setup))
;; IVY-RICH
;; comes with rich transformers for commands from ivy and counsel.
;; https://github.com/Yevgnen/ivy-rich
(use-package ivy-rich
:after ivy
:defer .5
:hook (counsel-mode . ivy-rich-mode)
:config
;; For better performance
;; Better experience with icons
(setq ivy-rich-parse-remote-buffer nil))
;; ALL THE ICONS IVY RICH
;; extracted from Centaur Emacs and leverages ivy-rich and all-the-icons.
;; https://github.com/seagle0128/all-the-icons-ivy-rich
(use-package all-the-icons-ivy-rich
:defer .5
:after (all-the-icons ivy-rich)
:config
(all-the-icons-ivy-rich-mode 1)
(setq all-the-icons-ivy-rich-icon-size 0.8))
;; ----------------------------------- Swiper ----------------------------------
;; Swiper displays an overview of all matches, leveraging Ivy.
(use-package swiper
:defer .5
:bind
(("C-s" . swiper)
("M-s" . swiper-isearch-thing-at-point))
:config
(setq swiper-action-recenter t) ;; recenter after selection
(setq swiper-goto-start-of-match t)) ;; jump to the beginning of match after selection
;; --------------------------------- Marginalia --------------------------------
;; Enables richer annotations in the selection framework
(use-package marginalia
:defer .5
;; Either bind `marginalia-cycle` globally or only in the minibuffer
:bind (("M-A" . marginalia-cycle)
:map minibuffer-local-map
("M-A" . marginalia-cycle))
:config
(marginalia-mode))
;; --------------------------------- Prescient ---------------------------------
;; Sorts and filters candidates that appear when you use a package like Ivy or Company.
(use-package prescient
:defer .5
:config
(setq prescient-sort-full-matches-first t))
;; IVY PRESCIENT: Prescient integration with Ivy
(use-package ivy-prescient
:defer .5
:after (ivy prescient)
:config
(ivy-prescient-mode 1))
(provide 'selection-framework)
;;; selection-framework.el ends here
|