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.
This commit is contained in:
Dmitry Gutov 2021-05-15 02:47:05 +03:00
parent efc24f1e0b
commit 76ba00a161

View 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)