-
Notifications
You must be signed in to change notification settings - Fork 0
/
auto-complete-yasnippet.el
38 lines (32 loc) · 1.16 KB
/
auto-complete-yasnippet.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
(require 'auto-complete)
(require 'yasnippet)
(defun ac-yasnippet-candidate-1 (table)
(let ((hashtab (yas/snippet-table-hash table))
(parent (yas/snippet-table-parent table))
candidates)
(maphash (lambda (key value)
(push key candidates))
hashtab)
(setq candidates (all-completions ac-prefix (nreverse candidates)))
(if parent
(setq candidates
(append candidates (ac-yasnippet-candidate-1 parent))))
candidates))
(defun ac-yasnippet-candidate ()
(let ((table (yas/snippet-table major-mode)))
(if table
(ac-yasnippet-candidate-1 table))))
(defface ac-yasnippet-candidate-face
'((t (:background "sandybrown" :foreground "black")))
"Face for yasnippet candidate.")
(defface ac-yasnippet-selection-face
'((t (:background "coral3" :foreground "white")))
"Face for the yasnippet selected candidate.")
(defvar ac-source-yasnippet
'((candidates . ac-yasnippet-candidate)
(action . yas/expand)
(limit . 3)
(candidate-face . ac-yasnippet-candidate-face)
(selection-face . ac-yasnippet-selection-face))
"Source for Yasnippet.")
(provide 'auto-complete-yasnippet)