diff options
author | Maciej Barć <xgqt@gentoo.org> | 2022-08-17 00:36:25 +0200 |
---|---|---|
committer | Maciej Barć <xgqt@gentoo.org> | 2022-08-17 00:36:25 +0200 |
commit | dec99c179e3a934cba6a77c76996102b9fcb9bda (patch) | |
tree | 5746c60bdb1db65edf6c25ab78d08b83493c43c1 | |
parent | company-ebuild.el: do not require a match (diff) | |
download | company-ebuild-dec99c179e3a934cba6a77c76996102b9fcb9bda.tar.gz company-ebuild-dec99c179e3a934cba6a77c76996102b9fcb9bda.tar.bz2 company-ebuild-dec99c179e3a934cba6a77c76996102b9fcb9bda.zip |
company-ebuild.el: completion kinds
Signed-off-by: Maciej Barć <xgqt@gentoo.org>
-rw-r--r-- | company-ebuild.el | 41 |
1 files 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)) |