From 76ba00a1619d6bed27bc26578ffda6f4b43a4c6b Mon Sep 17 00:00:00 2001 From: Dmitry Gutov Date: Sat, 15 May 2021 02:47:05 +0300 Subject: [PATCH] Add :company-kind support to css-mode completion * lisp/textmodes/css-mode.el (css--complete-pseudo-element-or-class) (css--complete-property-value, css-completion-at-point) (css--complete-at-rule): Add :company-kind properties, to annotate completions with kinds returned in each case. --- lisp/textmodes/css-mode.el | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lisp/textmodes/css-mode.el b/lisp/textmodes/css-mode.el index 47b0b517ae0..879c24a2fe1 100644 --- a/lisp/textmodes/css-mode.el +++ b/lisp/textmodes/css-mode.el @@ -1310,7 +1310,8 @@ for determining whether point is within a selector." (list (point) pos (if (eq (char-before (- (point) 1)) ?\:) css-pseudo-element-ids - css-pseudo-class-ids)))))) + css-pseudo-class-ids) + :company-kind (lambda (_) 'function)))))) (defun css--complete-at-rule () "Complete at-rule (statement beginning with `@') at point." @@ -1318,7 +1319,8 @@ for determining whether point is within a selector." (let ((pos (point))) (skip-chars-backward "-[:alnum:]") (when (eq (char-before) ?\@) - (list (point) pos css--at-ids))))) + (list (point) pos css--at-ids + :company-kind (lambda (_) 'keyword)))))) (defvar css--property-value-cache (make-hash-table :test 'equal :size (length css-property-alist)) @@ -1366,7 +1368,8 @@ the string PROPERTY." (skip-chars-backward "[:graph:]") (list (point) end (append '("inherit" "initial" "unset") - (css--property-values (car property))))))))) + (css--property-values (car property))) + :company-kind (lambda (_) 'value))))))) (defvar css--html-tags (mapcar #'car html-tag-alist) "List of HTML tags. @@ -1435,6 +1438,8 @@ tags, classes and IDs." (list prop-beg prop-end) (list sel-beg sel-end)) ,(completion-table-merge prop-table sel-table) + :company-kind + ,(lambda (s) (if (test-completion s prop-table) 'property 'keyword)) :exit-function ,(lambda (string status) (and (eq status 'finished) -- 2.39.5