1 |
commit: dec99c179e3a934cba6a77c76996102b9fcb9bda |
2 |
Author: Maciej Barć <xgqt <AT> gentoo <DOT> org> |
3 |
AuthorDate: Tue Aug 16 22:36:25 2022 +0000 |
4 |
Commit: Maciej Barć <xgqt <AT> gentoo <DOT> org> |
5 |
CommitDate: Tue Aug 16 22:36:25 2022 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/company-ebuild.git/commit/?id=dec99c17 |
7 |
|
8 |
company-ebuild.el: completion kinds |
9 |
|
10 |
Signed-off-by: Maciej Barć <xgqt <AT> gentoo.org> |
11 |
|
12 |
company-ebuild.el | 41 ++++++++++++++++++++++------------------- |
13 |
1 file changed, 22 insertions(+), 19 deletions(-) |
14 |
|
15 |
diff --git a/company-ebuild.el b/company-ebuild.el |
16 |
index 65c5aef..e8916b7 100644 |
17 |
--- a/company-ebuild.el |
18 |
+++ b/company-ebuild.el |
19 |
@@ -51,44 +51,44 @@ |
20 |
"Company-Ebuild version.") |
21 |
|
22 |
|
23 |
-(defun company-ebuild--annotation (candidate) |
24 |
+(defun company-ebuild--annotation-and-kind (candidate) |
25 |
"Return annotation for CANDIDATE." |
26 |
(cond |
27 |
((member candidate company-ebuild--constant-keywords-architectures) |
28 |
- " architecture") |
29 |
+ '(" architecture" . value)) |
30 |
((member candidate company-ebuild--constant-keywords-restrict) |
31 |
- " restrict") |
32 |
+ '(" restrict" . value)) |
33 |
((member candidate company-ebuild--constant-keywords-phases) |
34 |
- " phase") |
35 |
+ '(" phase" . function)) |
36 |
((member candidate company-ebuild--constant-keywords-sandbox) |
37 |
- " sandbox") |
38 |
+ '(" sandbox" . function)) |
39 |
((member candidate company-ebuild--constant-keywords-doc) |
40 |
- " doc") |
41 |
+ '(" doc" . variable)) |
42 |
((member candidate company-ebuild--constant-keywords-variables-predefined) |
43 |
- " variable (predefined)") |
44 |
+ '(" variable (predefined)" . variable)) |
45 |
((member candidate company-ebuild--constant-keywords-variables-ebuild-defined) |
46 |
- " variable (ebuild-defined)") |
47 |
+ '(" variable (ebuild-defined)" . variable)) |
48 |
((member candidate company-ebuild--constant-keywords-variables-dependencies) |
49 |
- " variable (dependencies)") |
50 |
+ '(" variable (dependencies)" . variable)) |
51 |
((member candidate company-ebuild--constant-keywords-variables-user-environment) |
52 |
- " variable (user-environment)") |
53 |
+ '(" variable (user-environment)" . variable)) |
54 |
((member candidate company-ebuild--dynamic-keywords-eclasses) |
55 |
- " eclass") |
56 |
+ '(" eclass" . module)) |
57 |
((or (member candidate company-ebuild--constant-keywords-functions) |
58 |
(member candidate company-ebuild--dynamic-keywords-functions)) |
59 |
- " function") |
60 |
+ '(" function" . function)) |
61 |
((member candidate company-ebuild--dynamic-keywords-variables) |
62 |
- " variable (eclass)") |
63 |
+ '(" variable (eclass)" . variable)) |
64 |
((member candidate company-ebuild--dynamic-keywords-use-flags) |
65 |
- " USE flag") |
66 |
+ '(" USE flag" . value)) |
67 |
((member candidate company-ebuild--dynamic-keywords-packages) |
68 |
- " package") |
69 |
+ '(" package" . value)) |
70 |
((member candidate company-ebuild--dynamic-keywords-licenses) |
71 |
- " license") |
72 |
+ '(" license" . value)) |
73 |
((executable-find candidate) |
74 |
- " executable") |
75 |
+ '(" executable" . file)) |
76 |
(t |
77 |
- ""))) |
78 |
+ '("" . t)))) |
79 |
|
80 |
(defun company-ebuild--packages () |
81 |
"Return a list of all available packages. |
82 |
@@ -229,7 +229,7 @@ ARG is the completion argument for annotation and candidates." |
83 |
(interactive (list 'interactive)) |
84 |
(cl-case command |
85 |
(annotation |
86 |
- (company-ebuild--annotation arg)) |
87 |
+ (car (company-ebuild--annotation-and-kind arg))) |
88 |
(candidates |
89 |
;; TODO: Complete any string that already appears in current buffer. |
90 |
(cl-remove-if-not (lambda (candidate) |
91 |
@@ -239,6 +239,8 @@ ARG is the completion argument for annotation and candidates." |
92 |
(company-ebuild--executables arg)))) |
93 |
(interactive |
94 |
(company-begin-backend 'company-ebuild)) |
95 |
+ (kind |
96 |
+ (cdr (company-ebuild--annotation-and-kind arg))) |
97 |
(prefix |
98 |
(and (eq major-mode 'ebuild-mode) (company-grab-symbol))) |
99 |
(require-match |
100 |
@@ -256,6 +258,7 @@ or `require' Company-Ebuild: |
101 |
;; HACK: Modify syntax to treat "/" as a word constituent. |
102 |
;; TODO: (Hard mode) write a proper `company-grab-symbol' replacement. |
103 |
(modify-syntax-entry ?/ "w") |
104 |
+ (modify-syntax-entry ?@ "w") ; To make Eclass tags work. |
105 |
;; Force-enable `company-mode'. |
106 |
(when (null company-mode) |
107 |
(company-mode +1)) |