mirror of
https://github.com/jimeh/.emacs.d.git
synced 2026-02-19 13:46:41 +00:00
chore(treesit): add extra helper functions
This commit is contained in:
@@ -26,6 +26,13 @@
|
||||
"Add font-lock features to treesit."
|
||||
(add-to-list 'treesit-font-lock-feature-list features) t)
|
||||
|
||||
(defun siren-treesit-prepend-font-lock-settings (&rest query-specs)
|
||||
"Replace existing features in font-lock settings, retaining feature order."
|
||||
(setq-local
|
||||
treesit-font-lock-settings
|
||||
(append (apply 'treesit-font-lock-rules query-specs)
|
||||
treesit-font-lock-settings)))
|
||||
|
||||
(defun siren-treesit-append-font-lock-settings (&rest query-specs)
|
||||
"Replace existing features in font-lock settings, retaining feature order."
|
||||
(setq-local
|
||||
@@ -33,7 +40,6 @@
|
||||
(append treesit-font-lock-settings
|
||||
(apply 'treesit-font-lock-rules query-specs))))
|
||||
|
||||
|
||||
(defun siren-treesit-add-font-lock-settings (&rest query-specs)
|
||||
"Add features after existing ones in font-lock settings."
|
||||
(dolist (item (apply 'treesit-font-lock-rules query-specs))
|
||||
@@ -59,6 +65,11 @@
|
||||
treesit-font-lock-settings
|
||||
(apply 'treesit-font-lock-rules query-specs))))
|
||||
|
||||
(defun siren-treesit-get-font-lock-rule (feature)
|
||||
"Get the current treesit font-lock settings."
|
||||
(cl-find-if (lambda (x) (eq (siren-treesit--feature x) feature))
|
||||
treesit-font-lock-settings))
|
||||
|
||||
(defun siren-treesit--feature (compiled-query)
|
||||
"Get the feature from a compiled treesit query."
|
||||
(nth 2 compiled-query))
|
||||
|
||||
Reference in New Issue
Block a user