blob: 07035d646f2842e0dd7b0b4372561c814155660e (
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
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
|
#+title: Completion configuration using ivy, counsel and friends
* ivy
#+begin_src emacs-lisp
(use-package ivy
:ensure t
:demand t
:custom
((ivy-count-format "(%d/%d) ")
(ivy-do-completion-in-region t)
(ivy-height 20)
(ivy-re-builders-alist '((counsel-ag . ivy--regex)
(counsel-rg . ivy--regex)
(counsel-yank-pop . ivy--regex)
(swiper . ivy--regex)
(swiper-isearch . ivy--regex)
(t . ivy--regex-fuzzy)))
(ivy-use-virtual-buffers t)
(ivy-virtual-abbreviate 'abbreviate)
(ivy-wrap t))
:config
;; used by ivy--regex-fuzzy to order results
(use-package flx :ensure t)
;; Try C-o in the minibuffer
(use-package ivy-hydra
:after ivy
:ensure t
:init (setq ivy-read-action-function #'ivy-hydra-read-action))
(add-to-list 'ivy-initial-inputs-alist
'(gnus-summary-move-article . ""))
:bind (("C-R" . ivy-resume)
("C-x b" . ivy-switch-buffer)
("C-c v" . ivy-push-view)
("C-c V" . ivy-pop-view))
:diminish)
#+end_src
* counsel
#+begin_src emacs-lisp
(use-package counsel
:ensure t
:custom ((counsel-describe-function-function 'helpful-callable)
(counsel-describe-variable-function 'helpful-variable)
(counsel-find-file-at-point t)
(counsel-linux-app-format-function
#'counsel-linux-app-format-function-name-pretty)
(counsel-mode-override-describe-bindings nil)
(counsel-recentf-include-xdg-list t))
:config
:bind (("C-s" . swiper-isearch)
("C-S-s" . isearch-forward)
("M-x" . counsel-M-x)
("C-x f" . counsel-find-file)
("C-c k" . counsel-ag)
("C-c K" . counsel-rg)
("C-c l" . counsel-locate)
("C-c b" . counsel-git)
("C-c i" . counsel-imenu)
("C-c G" . counsel-search)
("s-r" . counsel-linux-app))
:diminish)
#+end_src
* counsel add-ons
*** recoll
#+BEGIN_SRC emacs-lisp
(use-package jao-recoll)
(use-package jao-counsel-recoll
:after counsel
:bind (("C-c R" . jao-counsel-recoll)))
#+END_SRC
*** notmuch
#+begin_src emacs-lisp
(use-package counsel-notmuch
:ensure t
:config (with-eval-after-load "gnus-group"
(define-key gnus-group-mode-map "Gg" 'counsel-notmuch)))
#+end_src
* ivy rich
#+begin_src emacs-lisp
(use-package ivy-rich
:after (ivy counsel)
:ensure t
:custom ((ivy-rich-path-style 'relative)
(ivy-rich-parse-remote-buffer nil)
(ivy-rich-parse-remote-file-path nil))
:config
(ivy-rich-modify-columns
'ivy-switch-buffer
'((ivy-rich-candidate (:width 80))
(ivy-rich-switch-buffer-indicators (:face jao-themes-f00))
(ivy-rich-switch-buffer-project (:width 15))
(ivy-rich-switch-buffer-major-mode (:width 15 :face jao-themes-f12)))))
#+end_src
* dap
#+begin_src emacs-lisp
(jao-load-path "dap")
(use-package dap
:demand t
:bind (("C-'" . dap-dap)))
#+end_src
*** prompter
#+begin_src emacs-lisp
(defun jao-dap--hide-help ()
(when-let ((w (get-buffer-window (help-buffer))))
(with-selected-window w (kill-buffer-and-window))))
(defun jao-dap--prompter (keymap)
(let ((display-buffer-alist '(("*Help*"
(display-buffer-at-bottom)
(window-parameters (mode-line-format . none))
(window-height . fit-window-to-buffer)))))
(let ((inhibit-message t))
(describe-keymap keymap))))
(defun jao-dap--prompter-done ()
(save-current-buffer (jao-dap--hide-help)))
(setq dap-prompter #'jao-dap--prompter)
(setq dap-prompter-done #'jao-dap--prompter-done)
#+end_src
*** minibuffer actions
#+begin_src emacs-lisp
(defun jao-dap--completion-metadata ()
(completion-metadata
(buffer-substring-no-properties (field-beginning) (point))
minibuffer-completion-table
minibuffer-completion-predicate))
(defun jao-dap--completion-category ()
(completion-metadata-get (jao-dap--completion-metadata) 'category))
(dap-define-keymap jao-dap-buffer-map
"Keymap for buffer actions."
("k" kill-buffer)
("b" switch-to-buffer)
("o" switch-to-buffer-other-window)
("z" bury-buffer)
("q" kill-buffer-and-window)
("=" ediff-buffers))
(dap-define-keymap espotify-item-keymap
"Actions for Spotify search results"
("a" espotify--play-album)
("h" espotify--show-info))
(defvar jao-dap--smaps
'((command . dap-command-map)
(espotify-search-item . espotify-item-keymap)
(function . dap-function-map)
(variable . dap-variable-map)
(face . dap-face-map)
(buffer . jao-dap-buffer-map)
(consult-buffer . jao-dap-buffer-map)))
(defun jao-dap-target-minibuffer-candidate ()
(when (minibuffer-window-active-p (selected-window))
(let ((cand (ivy-state-current ivy-last))
(cat (jao-dap--completion-category)))
(when-let (m (alist-get cat jao-dap--smaps))
(cons m cand)))))
(add-to-list 'dap-targets #'jao-dap-target-minibuffer-candidate)
#+end_src
*** url / video actions
#+begin_src emacs-lisp
(defvar jao-dap-video-url-rx
(format "^https?://\\(?:www\\.\\)?%s/.+"
(regexp-opt '("youtu.be"
"youtube.com"
"blip.tv"
"vimeo.com"
"infoq.com")
t))
"A regular expression matching URLs that point to video streams")
(defun jao-dap--play-video (player url)
(interactive "sURL: ")
(let ((cmd (format "%s %s" player (shell-quote-argument url))))
(start-process-shell-command player nil cmd)))
(defun jao-dap-mpv (&optional url)
"Play video stream with mpv"
(interactive "sURL: ")
(jao-dap--play-video "mpv" url))
(defun jao-dap-vlc (&optional url)
"Play video stream with vlc"
(interactive "sURL: ")
(jao-dap--play-video "vlc" url))
(defun jao-dap-target-w3m-url ()
(when-let (url (or (thing-at-point-url-at-point)
(w3m-anchor)
w3m-current-url))
(cons 'dap-url-map url)))
(defun jao-dap-kill (&optional x)
"Save to kill ring"
(interactive "s")
(kill-new x))
(define-key dap-url-map "f" #'browse-url-firefox)
(define-key dap-url-map "w" #'jao-dap-kill)
(define-key dap-url-map [return] #'browse-url)
(defun jao-dap-target-video-url ()
(when-let (url (jao-dap-target-w3m-url))
(when (string-match-p jao-dap-video-url-rx (cdr url))
(cons 'jao-dap-video-url-map (cdr url)))))
(dap-define-keymap jao-dap-video-url-map
"Actions on URLs pointing to remote video streams."
("v" jao-dap-vlc)
("m" jao-dap-mpv))
(add-to-list 'dap-targets #'jao-dap-target-w3m-url)
(add-to-list 'dap-targets #'jao-dap-target-video-url)
#+end_src
* startup
#+begin_src emacs-lisp
(ivy-mode 1)
(counsel-mode 1)
(ivy-rich-mode 1)
(ivy-rich-project-root-cache-mode 1)
#+end_src
|