diff options
author | Yuan Fu <casouri@gmail.com> | 2022-11-21 11:26:46 -0800 |
---|---|---|
committer | Yuan Fu <casouri@gmail.com> | 2022-11-21 11:26:46 -0800 |
commit | 6cf8bf504285d9b8caf10ebdb3d5b61671a533ef (patch) | |
tree | bf9b6ba23b71a3ae9af9f3a1edfeb0bb095e4d56 /lisp/textmodes/css-mode.el | |
parent | 0cbb7d3bd098e80b58457cb58125cc67e56415a2 (diff) | |
download | emacs-6cf8bf504285d9b8caf10ebdb3d5b61671a533ef.tar.gz |
Allow major modes to tweak tree-sitter fontification
treesit--font-lock-query-expand-range allows a major mode to fix
fontification problems temporarily before the parser can be fixed.
* lisp/treesit.el (treesit--font-lock-query-expand-range): New variable.
(treesit-font-lock-fontify-region): Use the new variable.
* lisp/textmodes/css-mode.el (css-ts-mode): Use the new variable.
Diffstat (limited to 'lisp/textmodes/css-mode.el')
-rw-r--r-- | lisp/textmodes/css-mode.el | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/lisp/textmodes/css-mode.el b/lisp/textmodes/css-mode.el index 35e6b9ce3ec..097d4f82415 100644 --- a/lisp/textmodes/css-mode.el +++ b/lisp/textmodes/css-mode.el @@ -1813,6 +1813,11 @@ can also be used to fill comments. '((selector comment) (property constant string) (error variable function))) + ;; Tree-sitter-css, for whatever reason, cannot reliably return + ;; the captured nodes in a given range (it instead returns the + ;; nodes preceding range). Before this is fixed in + ;; tree-sitter-css, use this heuristic as a temporary fix. + (setq-local treesit--font-lock-query-expand-range (cons 80 80)) (setq-local imenu-create-index-function #'css--treesit-imenu) (setq-local which-func-functions nil) (treesit-major-mode-setup))) |