]> git.eshelyaron.com Git - emacs.git/commitdiff
Add :company-kind support to css-mode completion
authorDmitry Gutov <dgutov@yandex.ru>
Fri, 14 May 2021 23:47:05 +0000 (02:47 +0300)
committerDmitry Gutov <dgutov@yandex.ru>
Sat, 15 May 2021 00:28:28 +0000 (03:28 +0300)
* 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

index 47b0b517ae0deffde0e436f416a59a4a507d5586..879c24a2fe159d1eef7000d6c87e23f057a2f2d6 100644 (file)
@@ -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)