Add color fontification in css-ts-mode (bug#60405)

* lisp/textmodes/css-mode.el (css-ts-mode): Add color fontification
and syntax-propertize-function.
This commit is contained in:
Yuan Fu 2022-12-29 11:52:06 -08:00
parent a96a7c8115
commit 558b59d81b
No known key found for this signature in database
GPG key ID: 56E19BC57664A442

View file

@ -1804,11 +1804,15 @@ can also be used to fill comments.
:syntax-table css-mode-syntax-table :syntax-table css-mode-syntax-table
(when (treesit-ready-p 'css) (when (treesit-ready-p 'css)
;; Borrowed from `css-mode'. ;; Borrowed from `css-mode'.
(setq-local syntax-propertize-function
css-syntax-propertize-function)
(add-hook 'completion-at-point-functions (add-hook 'completion-at-point-functions
#'css-completion-at-point nil 'local) #'css-completion-at-point nil 'local)
(setq-local fill-paragraph-function #'css-fill-paragraph) (setq-local fill-paragraph-function #'css-fill-paragraph)
(setq-local adaptive-fill-function #'css-adaptive-fill) (setq-local adaptive-fill-function #'css-adaptive-fill)
(setq-local add-log-current-defun-function #'css-current-defun-name) ;; `css--fontify-region' first calls the default function, which
;; will call tree-sitter's function, then it fontifies colors.
(setq-local font-lock-fontify-region-function #'css--fontify-region)
;; Tree-sitter specific setup. ;; Tree-sitter specific setup.
(treesit-parser-create 'css) (treesit-parser-create 'css)