about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-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)
rsion request tests' href='/danisanti/profani-tty/commit/tests/functionaltests/test_software.c?id=de747e3d46c1be9e3256716d8939148e0bc07a35'>de747e3d ^
2a921693 ^





7f98e013 ^
2a921693 ^



7f98e013 ^
2a921693 ^

7f98e013 ^



2a921693 ^




406b821b ^
2a921693 ^
ac3e7dd9 ^






7f98e013 ^
ac3e7dd9 ^



7f98e013 ^
ac3e7dd9 ^

7f98e013 ^

ac3e7dd9 ^






406b821b ^









7f98e013 ^
406b821b ^



7f98e013 ^
406b821b ^











7f98e013 ^
406b821b ^



7f98e013 ^
406b821b ^


7f98e013 ^
406b821b ^


7f98e013 ^
406b821b ^

7f98e013 ^

406b821b ^










ac3e7dd9 ^
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