about summary refs log tree commit diff stats
path: root/emacs-prelude
diff options
context:
space:
mode:
authorDavid Morgan <djm_uk@protonmail.com>2021-07-08 16:14:22 +0100
committerDavid Morgan <djm_uk@protonmail.com>2021-07-08 16:14:22 +0100
commited618f8019ee0441259aa62ea87bc71d39bc1f11 (patch)
tree657324e74d9b20b4473148a47b8da9ec1400b902 /emacs-prelude
parentfb8d648983005f5e6f3677bcb7b59e3df8991d8b (diff)
downloaddotfiles-ed618f8019ee0441259aa62ea87bc71d39bc1f11.tar.gz
Update config for consult, orderless, etc some more
Diffstat (limited to 'emacs-prelude')
-rw-r--r--emacs-prelude/personal/lisp/init-completion.el71
1 files changed, 64 insertions, 7 deletions
diff --git a/emacs-prelude/personal/lisp/init-completion.el b/emacs-prelude/personal/lisp/init-completion.el
index 6d7aeb9..4534ee0 100644
--- a/emacs-prelude/personal/lisp/init-completion.el
+++ b/emacs-prelude/personal/lisp/init-completion.el
@@ -19,16 +19,54 @@
 (prelude-require-package 'orderless)
 (use-package orderless
   :bind (:map minibuffer-local-completion-map
-         ("C-l" . my/match-components-literally))
+              ("C-l" . my/match-components-literally))
+  :custom (orderless-component-separator 'orderless-escapable-split-on-space)
   :init
   (setq completion-styles '(orderless)
         completion-category-defaults nil
-        completion-category-overrides '((file (styles . (partial-completion))))) ;; TODO initials instead of partial-completion?
+        completion-category-overrides '((file (styles . (partial-completion orderless)))))
+
   (defun my/match-components-literally ()
     "Components match literally for the rest of the session."
     (interactive)
     (setq-local orderless-matching-styles '(orderless-literal)
-                orderless-style-dispatchers nil)))
+                orderless-style-dispatchers nil))
+  :config
+  (defun flex-if-twiddle (pattern _index _total)
+    (when (string-suffix-p "~" pattern)
+      `(orderless-flex . ,(substring pattern 0 -1))))
+
+  (defun literal-if-hat (pattern _index _total)
+    (when (string-suffix-p "^" pattern)
+      `(orderless-literal . ,(substring pattern 0 -1))))
+
+  (defun literal-if-apostrophe (pattern _index _total)
+    (cond
+     ((equal "'" pattern)
+      '(orderless-literal . ""))
+     ((string-prefix-p "'" pattern)
+      `(orderless-literal . ,(substring pattern 1)))))
+
+  (defun initialism-if-comma (pattern _index _total)
+    (cond
+     ((equal "," pattern)
+      '(orderless-literal . ""))
+     ((string-prefix-p "," pattern)
+      `(orderless-initialism . ,(substring pattern 1)))))
+
+  (defun without-if-bang (pattern _index _total)
+    (cond
+     ((equal "!" pattern)
+      '(orderless-literal . ""))
+     ((string-prefix-p "!" pattern)
+      `(orderless-without-literal . ,(substring pattern 1)))))
+
+  (setq orderless-matching-styles '(orderless-literal orderless-regexp orderless-strict-leading-initialism)
+        orderless-style-dispatchers '(flex-if-twiddle
+                                      literal-if-hat
+                                      literal-if-apostrophe
+                                      initialism-if-comma
+                                      without-if-bang)))
 
 (use-package savehist
   :init
@@ -79,7 +117,8 @@
          ("M-'" . consult-register-store)          ;; orig. abbrev-prefix-mark (unrelated)
          ("C-M-#" . consult-register)
          ;; Other custom bindings
-         ("C-S" . consult-line)
+         ("C-S-s" . consult-line)
+         ("s-s" . consult-line-symbol-at-point)
          ("M-y" . consult-yank-pop)                ;; orig. yank-pop
          ("<help> a" . consult-apropos)            ;; orig. apropos-command
          ;; M-g bindings (goto-map)
@@ -139,7 +178,7 @@
    consult-theme
    :preview-key '(:debounce 0.2 any)
    consult-ripgrep consult-git-grep consult-grep
-   consult-bookmark consult-recent-file consult-xref
+   consult-bookmark consult-recent-file consult-xref consult-buffer
    consult--source-file consult--source-project-file consult--source-bookmark
    :preview-key (kbd "M-."))
 
@@ -152,7 +191,15 @@
   ;; (define-key consult-narrow-map (vconcat consult-narrow-key "?") #'consult-narrow-help)
 
   (autoload 'projectile-project-root "projectile")
-  (setq consult-project-root-function #'projectile-project-root))
+  (setq consult-project-root-function #'projectile-project-root)
+
+  (defun find-fd (&optional dir initial)
+    (interactive "P")
+    (let ((consult-find-command "fd --color=never --full-path ARG OPTS"))
+      (consult-find dir initial)))
+  (defun consult-line-symbol-at-point ()
+    (interactive)
+    (consult-line (thing-at-point 'symbol))))
 
 (prelude-require-package 'consult-flycheck)
 (use-package consult-flycheck)
@@ -198,5 +245,15 @@
   :hook
   (embark-collect-mode . consult-preview-at-point-mode))
 
-(provide 'init-completion)
+;; async fuzzy finder (uses consult and orderless)
+(use-package affe
+  :after orderless
+  :config
+  ;; Configure Orderless
+  (setq affe-regexp-function #'orderless-pattern-compiler
+        affe-highlight-function #'orderless--highlight)
+
+  ;; Manual preview key for `affe-grep'
+  (consult-customize affe-grep :preview-key (kbd "M-.")))
 
+(provide 'init-completion)
ef='/akkartik/mu/blame/075scenario_console.cc?h=main&id=16386f766ec1e347db8a19ebfd9cedaa9b281a5f'>^
a5840f21 ^
45c08fea ^
a5840f21 ^

70f70118 ^

a5840f21 ^
fb5470bc ^
263e6b2a ^
a5840f21 ^

263e6b2a ^


a5840f21 ^


263e6b2a ^
795f5244 ^



a5840f21 ^

45c08fea ^
263e6b2a ^
665fb11e ^

795f5244 ^
f3760b0f ^
795f5244 ^
665fb11e ^
5f98a10c ^
795f5244 ^
665fb11e ^
795f5244 ^
665fb11e ^

795f5244 ^
665fb11e ^
45c08fea ^

a5840f21 ^



263e6b2a ^
a5840f21 ^




263e6b2a ^
795f5244 ^
a5840f21 ^


263e6b2a ^
795f5244 ^
a5840f21 ^





c6034af3 ^

795f5244 ^
263e6b2a ^
c6034af3 ^
795f5244 ^
263e6b2a ^

a5840f21 ^


665fb11e ^







































bd345189 ^
665fb11e ^


















45c08fea ^


2dab0edb ^
45c08fea ^
665fb11e ^
45c08fea ^
2dab0edb ^

45c08fea ^
455fbac6 ^


45c08fea ^
455fbac6 ^
45c08fea ^
455fbac6 ^
45c08fea ^
455fbac6 ^
45c08fea ^

















8f060500 ^
665fb11e ^
45c08fea ^






2dab0edb ^

4938a720 ^
fedebaf5 ^




795f5244 ^
166e3c0d ^



fedebaf5 ^


795f5244 ^
5f98a10c ^
35064671 ^

795f5244 ^


fedebaf5 ^
795f5244 ^

fedebaf5 ^
795f5244 ^
fedebaf5 ^



4938a720 ^




4938a720 ^



4938a720 ^







343bc535 ^
4938a720 ^
c6034af3 ^
4938a720 ^


c6034af3 ^
4938a720 ^


795f5244 ^
343bc535 ^
263e6b2a ^
c6034af3 ^
4938a720 ^

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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295