commit:     dec99c179e3a934cba6a77c76996102b9fcb9bda
Author:     Maciej Barć <xgqt <AT> gentoo <DOT> org>
AuthorDate: Tue Aug 16 22:36:25 2022 +0000
Commit:     Maciej Barć <xgqt <AT> gentoo <DOT> org>
CommitDate: Tue Aug 16 22:36:25 2022 +0000
URL:        
https://gitweb.gentoo.org/proj/company-ebuild.git/commit/?id=dec99c17

company-ebuild.el: completion kinds

Signed-off-by: Maciej Barć <xgqt <AT> gentoo.org>

 company-ebuild.el | 41 ++++++++++++++++++++++-------------------
 1 file changed, 22 insertions(+), 19 deletions(-)

diff --git a/company-ebuild.el b/company-ebuild.el
index 65c5aef..e8916b7 100644
--- a/company-ebuild.el
+++ b/company-ebuild.el
@@ -51,44 +51,44 @@
   "Company-Ebuild version.")
 
 
-(defun company-ebuild--annotation (candidate)
+(defun company-ebuild--annotation-and-kind (candidate)
   "Return annotation for CANDIDATE."
   (cond
    ((member candidate company-ebuild--constant-keywords-architectures)
-    " architecture")
+    '(" architecture" . value))
    ((member candidate company-ebuild--constant-keywords-restrict)
-    " restrict")
+    '(" restrict" . value))
    ((member candidate company-ebuild--constant-keywords-phases)
-    " phase")
+    '(" phase" . function))
    ((member candidate company-ebuild--constant-keywords-sandbox)
-    " sandbox")
+    '(" sandbox" . function))
    ((member candidate company-ebuild--constant-keywords-doc)
-    " doc")
+    '(" doc" . variable))
    ((member candidate company-ebuild--constant-keywords-variables-predefined)
-    " variable (predefined)")
+    '(" variable (predefined)" . variable))
    ((member candidate 
company-ebuild--constant-keywords-variables-ebuild-defined)
-    " variable (ebuild-defined)")
+    '(" variable (ebuild-defined)" . variable))
    ((member candidate company-ebuild--constant-keywords-variables-dependencies)
-    " variable (dependencies)")
+    '(" variable (dependencies)" . variable))
    ((member candidate 
company-ebuild--constant-keywords-variables-user-environment)
-    " variable (user-environment)")
+    '(" variable (user-environment)" . variable))
    ((member candidate company-ebuild--dynamic-keywords-eclasses)
-    " eclass")
+    '(" eclass" . module))
    ((or (member candidate company-ebuild--constant-keywords-functions)
         (member candidate company-ebuild--dynamic-keywords-functions))
-    " function")
+    '(" function" . function))
    ((member candidate company-ebuild--dynamic-keywords-variables)
-    " variable (eclass)")
+    '(" variable (eclass)" . variable))
    ((member candidate company-ebuild--dynamic-keywords-use-flags)
-    " USE flag")
+    '(" USE flag" . value))
    ((member candidate company-ebuild--dynamic-keywords-packages)
-    " package")
+    '(" package" . value))
    ((member candidate company-ebuild--dynamic-keywords-licenses)
-    " license")
+    '(" license" . value))
    ((executable-find candidate)
-    " executable")
+    '(" executable" . file))
    (t
-    "")))
+    '("" . t))))
 
 (defun company-ebuild--packages ()
   "Return a list of all available packages.
@@ -229,7 +229,7 @@ ARG is the completion argument for annotation and 
candidates."
   (interactive (list 'interactive))
   (cl-case command
     (annotation
-     (company-ebuild--annotation arg))
+     (car (company-ebuild--annotation-and-kind arg)))
     (candidates
      ;; TODO: Complete any string that already appears in current buffer.
      (cl-remove-if-not (lambda (candidate)
@@ -239,6 +239,8 @@ ARG is the completion argument for annotation and 
candidates."
                                (company-ebuild--executables arg))))
     (interactive
      (company-begin-backend 'company-ebuild))
+    (kind
+     (cdr (company-ebuild--annotation-and-kind arg)))
     (prefix
      (and (eq major-mode 'ebuild-mode) (company-grab-symbol)))
     (require-match
@@ -256,6 +258,7 @@ or `require' Company-Ebuild:
   ;; HACK: Modify syntax to treat "/" as a word constituent.
   ;; TODO: (Hard mode) write a proper `company-grab-symbol' replacement.
   (modify-syntax-entry ?/ "w")
+  (modify-syntax-entry ?@ "w")  ; To make Eclass tags work.
   ;; Force-enable `company-mode'.
   (when (null company-mode)
     (company-mode +1))

Reply via email to