-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgs-completion.el
139 lines (127 loc) · 5 KB
/
gs-completion.el
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
;;; -*- lexical-binding: t -*-
(use-package orderless
:vc (:url "https://github.com/oantolin/orderless")
:config
(orderless-define-completion-style minad/orderless-initialism
(orderless-matching-styles '(orderless-initialism
orderless-literal
orderless-regexp)))
(orderless-define-completion-style minad/orderless-simple
(orderless-style-dispatchers nil)
(orderless-matching-styles '(orderless-literal)))
(defun minad/orderless--consult-suffix ()
"Regexp which matches the end of string with Consult tofu support."
(if (and (boundp 'consult--tofu-char) (boundp 'consult--tofu-range))
(format "[%c-%c]*$"
consult--tofu-char
(+ consult--tofu-char consult--tofu-range -1)) "$"))
;; Recognizes the following patterns:
;; * .ext (file extension)
;; * regexp$ (regexp matching at end)
(defun minad/orderless-consult-dispatch (word _index _total)
"Ensure that $ works with Consult commands, witch add disambiguation suffixes."
(cond
((string-suffix-p "$" word)
`(orderless-regexp . ,(concat (substring word 0 -1) (minad/orderless--consult-suffix))))
;; File extensions
((and (or minibuffer-completing-file-name
(derived-mode-p 'eshell-mode))
(string-match-p "\\`\\.." word))
`(orderless-regexp . ,(concat "\\." (substring word 1) (minad/orderless--consult-suffix))))))
:custom
(completion-styles '(orderless basic))
(completion-preview-completion-styles '(orderless basic))
(completion-category-defaults nil)
(completion-category-overrides '((file (styles partial-completion))
(command (styles minad/orderless-initialism))
(variable (styles minad/orderless-initialism))
(symbol (styles minad/orderless-initialism))
(minibuffer (styles minad/orderless-initialism))))
(orderless-comment-separator #'orderless-escapable-split-on-space)
(orderless-style-dispatchers (list #'minad/orderless-consult-dispatch
#'orderless-affix-dispatch))
:ensure t)
(use-package cape
:vc (:url "https://github.com/minad/cape")
:ensure t
:config
(advice-add #'eglot-completion-at-point :around #'cape-wrap-buster)
:hook
(completion-at-point-functions . cape-dabbrev)
(completion-at-point-functions . cape-file))
(use-package cape
:config
(defun minad/emacs-lisp-ignore-keywords (cand)
"Remove keywords from the CAND list, unless the completion text
starts with a `:'."
(or (not (keywordp cand))
(eq (char-after (car completion-in-region--data)) ?:)))
(defun minad/emacs-lisp-capf ()
"`completion-at-point-functions' for `emacs-lisp-mode', including
support for symbols currently unknown to Emacs, using `cape-dabbrev'.
Also adds `cape-file' as a fallback."
(setq-local completion-at-point-functions
`(,(cape-capf-super
(cape-capf-predicate
#'elisp-completion-at-point
#'minad/emacs-lisp-ignore-keywords)
#'cape-dabbrev)
cape-file)
cape-dabbrev-min-length 5))
:hook
(emacs-lisp-mode . minad/emacs-lisp-capf))
(use-package corg
:vc (:url "https://github.com/isamert/corg.el")
:ensure t
:hook
(org-mode . corg-setup))
(use-package tempel
:vc (:url "https://github.com/minad/tempel")
:bind
("C-z i s" . tempel-insert)
:ensure t)
(use-package lsp-snippet
:after tempel eglot
:vc (:url "https://github.com/svaante/lsp-snippet")
:config
(lsp-snippet-tempel-eglot-init))
(use-package tempel-snippets
:vc (:url "https://github.com/gs-101/tempel-snippets")
:after tempel
:ensure t)
(use-package vertico
:vc
(:url "https://github.com/minad/vertico" :lisp-dir "extensions")
:custom
(vertico-cycle t)
:ensure t
:init
(vertico-mode)
(vertico-multiform-mode))
(use-package vertico-directory
:after vertico
:bind
(:map vertico-map
("RET" . vertico-directory-enter)
("DEL" . vertico-directory-delete-char)
("M-DEL" . vertico-directory-delete-word))
:hook
(rfn-eshadow-update-overlay . vertico-directory-tidy))
(use-package vertico-multiform
:after vertico
:config
(defun minad/sort-directories-first (files)
"Sort FILES by directories first, but still maintain the history,
length and alphabetical sorting. Hidden directories have a higher priority."
(setq files (vertico-sort-history-length-alpha files))
(nconc (seq-filter (lambda (x) (string-suffix-p "/" x)) files)
(seq-remove (lambda (x) (string-suffix-p "/" x)) files)))
:custom
(vertico-multiform-categories '((symbol (vertico-sort-function . vertico-sort-alpha))
(file (vertico-sort-function . minad/sort-directories-first)))))
(use-package marginalia
:vc (:url "https://github.com/minad/marginalia")
:ensure t
:init
(marginalia-mode))
(provide 'gs-completion)