;ELC ;;; Compiled ;;; in Emacs version 28.0.50 ;;; with all optimizations. (byte-code "\300\301!\210\302\303\304\305\306\301%\210\302\307\304\310\306\303%\210\311\312\313\314\306\307%\210\311\315\316\317\306\307%\210\311\320\321\322\306\307%\210\311\323\324\325\306\307%\210\311\326\327\330\306\307%\210\311\331\332\333\306\307%\210\311\334\335\336\306\307%\210\337\340\341\331#\210\337\340\342\343\344!\206\\\345#\210\337\346\341\334#\210\337\346\342\343\344!\206n\345#\210\311\347\350\351\306\307%\210\311\352\353\354\306\307%\210\311\355\356\357\306\307%\210\311\360\361\362\306\307%\210\311\363\364\365\306\307%\210\311\366\367\370\306\307%\210\311\371\372\373\306\307%\210\311\374\375\376\306\307%\210\311\377\201@\201A\306\307%\210\311\201B\201C\201D\306\307%\210\311\201E\201F\201G\306\307%\210\311\201H\201I\201J\306\307%\210\311\201K\201L\201M\306\307%\210\311\201N\201O\201P\306\307%\210\311\201Q\201R\201S\306\307%\210\311\201T\201U\201V\306\307%\210\311\201W\201X\201Y\306\307%\210\311\201Z\201[\201\\\306\307%\210\311\201]\201^\201_\306\307%\210\311\201`\201a\201b\306\307%\210\311\201c\201d\201e\306\307%\210\311\201f\201g\201h\306\307%\210\311\201i\201j\201k\306\307%\210\311\201l\201m\201n\306\307%\210\311\201o\201p\201q\306\307%\210\311\201r\201s\201t\306\307%\210\311\201u\201v\201w\306\307%\210\311\201x\201y\201z\306\307%\210\311\201{\201|\201}\306\307%\210\311\201~\201\201\200\306\307%\210\201\201\201\202\201\203\201\204\201\205DD\201\206\306\303\201\207\201\210&\210\201\201\201\211\201\203\201\204\201\212DD\201\213\306\303\201\207\201\204&\207" [require tree-sitter custom-declare-group tree-sitter-hl nil "Syntax highlighting using tree-sitter." :group tree-sitter-hl-faces "Faces for highlighting code." custom-declare-face tree-sitter-hl-face:function ((default :inherit font-lock-function-name-face)) "Face for function declarations, definitions and bindings." tree-sitter-hl-face:function\.call ((default :inherit (link font-lock-function-name-face) :underline nil)) "Face for function calls." tree-sitter-hl-face:function\.builtin ((default :inherit font-lock-builtin-face)) "Face for builtin functions." tree-sitter-hl-face:function\.special ((default :inherit font-lock-preprocessor-face)) "Face for functions that alter things at compile/load time." tree-sitter-hl-face:function\.macro ((default :inherit font-lock-preprocessor-face)) "Face for macro calls." tree-sitter-hl-face:method ((default :inherit tree-sitter-hl-face:function)) "Face for method declarations and definitions." tree-sitter-hl-face:method\.call ((default :inherit tree-sitter-hl-face:function\.call)) "Face for method invocations." put tree-sitter-hl-face:function\.method face-alias obsolete-face purecopy "0.9.0" t tree-sitter-hl-face:function\.method\.call tree-sitter-hl-face:type ((default :inherit font-lock-type-face)) "Face for types." tree-sitter-hl-face:type\.parameter ((default :inherit font-lock-variable-name-face)) "Face for type parameters." tree-sitter-hl-face:type\.argument ((default :inherit tree-sitter-hl-face:type)) "Face for type arguments." tree-sitter-hl-face:type\.builtin ((default :inherit font-lock-builtin-face)) "Face for builtin types." tree-sitter-hl-face:type\.super ((default :inherit tree-sitter-hl-face:type)) "Face for super types in definitions and type constraints." tree-sitter-hl-face:constructor ((default :inherit tree-sitter-hl-face:type)) "Face for constructors." tree-sitter-hl-face:variable ((default :inherit font-lock-variable-name-face)) "Face for variable declarations, definitions, bindings and mutations." tree-sitter-hl-face:variable\.parameter ((default :inherit tree-sitter-hl-face:variable)) "Face for function parameters." tree-sitter-hl-face:variable\.builtin ((default :inherit font-lock-builtin-face)) "Face for builtin variables." tree-sitter-hl-face:variable\.special ((default :inherit font-lock-warning-face)) "Face for \"dangerous\" variables, e.g. mutable or dynamically-bound." tree-sitter-hl-face:property ((default :inherit font-lock-constant-face :slant italic)) "Face for properties." tree-sitter-hl-face:property\.definition ((default :inherit tree-sitter-hl-face:variable\.parameter)) "Face for property declarations and definitions." tree-sitter-hl-face:comment ((default :inherit font-lock-comment-face)) "Face for comments." tree-sitter-hl-face:doc ((default :inherit font-lock-doc-face)) "Face for docstrings." tree-sitter-hl-face:string ((default :inherit font-lock-string-face)) "Face for strings." tree-sitter-hl-face:string\.special ((default :inherit tree-sitter-hl-face:string :weight bold)) "Face for special strings, e.g. regular expressions." tree-sitter-hl-face:escape ((default :inherit font-lock-keyword-face)) "Face for escape characters in strings." tree-sitter-hl-face:embedded ((default :inherit default)) "Face for embedded expressions and code fragments." tree-sitter-hl-face:keyword ((default :inherit font-lock-keyword-face)) "Face for keywords." tree-sitter-hl-face:operator ((default :inherit tree-sitter-hl-face:keyword)) "Face for operators." tree-sitter-hl-face:label ((default :inherit font-lock-preprocessor-face)) "Face for labels." tree-sitter-hl-face:constant ((default :inherit font-lock-constant-face)) "Face for constants." tree-sitter-hl-face:constant\.builtin ((default :inherit font-lock-builtin-face)) "Face for builtin constants." tree-sitter-hl-face:number ((default :inherit tree-sitter-hl-face:constant)) "Face for numbers." tree-sitter-hl-face:punctuation ((default :inherit default)) "Face for punctuations." tree-sitter-hl-face:punctuation\.bracket ((default :inherit tree-sitter-hl-face:punctuation)) "Face for brackets." tree-sitter-hl-face:punctuation\.delimiter ((default :inherit tree-sitter-hl-face:punctuation)) "Face for delimiters." tree-sitter-hl-face:punctuation\.special ((default :inherit tree-sitter-hl-face:keyword)) "Face for special punctuations." tree-sitter-hl-face:tag ((default :inherit font-lock-builtin-face)) "Face for tags in markup languages." tree-sitter-hl-face:attribute ((default :inherit font-lock-preprocessor-face)) "Face for attributes markup languages." custom-declare-variable tree-sitter-hl-use-font-lock-keywords funcall function #[0 "\300\207" [:except-font-lock-defaults] 1] "Whether to keep using the highlighting provided by `font-lock-keywords'.\nIf `:except-font-lock-defaults', then keywords specified by `font-lock-defaults'\nare ignored, while keywords added through `font-lock-add-keywords' are used. The\nformer is typically set by major modes, while the latter is usually set by minor\nmodes and end users." :type (choice (const :tag "Yes" t) (const :tag "No" nil) (const :tag "Except `font-lock-defaults'" :except-font-lock-defaults)) tree-sitter-hl-face-mapping-function #[0 "\300\207" [tree-sitter-hl-face-from-common-scope] 1] "Function used to map capture names in query patterns to highlighting faces.\nThis can also be used to selectively disable certain capture names. For example,\nthe following code disables keyword highlighting:\n\n (add-function :before-while 'tree-sitter-hl-face-mapping-function\n (lambda (capture-name)\n (not (string= capture-name \"keyword\"))))"] 8) #@168 Default syntax highlighting patterns. This should be set by major modes that want to integrate with `tree-sitter-hl'. It plays a similar role to `font-lock-defaults'. (defvar tree-sitter-hl-default-patterns nil (#$ . 7297)) (make-variable-buffer-local 'tree-sitter-hl-default-patterns) #@182 Additional language-specific syntax highlighting patterns. It plays a similar role to `font-lock-keywords-alist', except that its keys are language symbols, not major mode symbols. (defvar tree-sitter-hl--patterns-alist nil (#$ . 7590)) (put 'tree-sitter-hl--patterns-alist 'risky-local-variable t) #@55 Additional buffer-local syntax highlighting patterns. (defvar tree-sitter-hl--extra-patterns-list nil (#$ . 7895)) (make-variable-buffer-local 'tree-sitter-hl--extra-patterns-list) #@66 Tree query used for syntax highlighting, compiled from patterns. (defvar tree-sitter-hl--query nil (#$ . 8082)) (make-variable-buffer-local 'tree-sitter-hl--query) #@74 Return the tree query to be used for syntax highlighting in this buffer. (defalias 'tree-sitter-hl--ensure-query #[0 "\204 \205\306\n\307\310\311 \312\313\n!\f\" C#\314# #\207" [tree-sitter-hl--query tree-sitter-hl-default-patterns tree-sitter-language tree-sitter-hl--extra-patterns-list tree-sitter-hl--patterns-alist tree-sitter-hl-face-mapping-function tsc-make-query mapconcat tsc--stringify-patterns append alist-get tsc--lang-symbol "\n"] 9 (#$ . 8252)]) #@76 Return the default face used to highlight CAPTURE-NAME. (fn CAPTURE-NAME) (defalias 'tree-sitter-hl-face-from-common-scope #[257 "\300\301\302\"!\207" [intern format "tree-sitter-hl-face:%s"] 5 (#$ . 8727)]) #@491 Add custom syntax highlighting PATTERNS. If LANG-SYMBOL is non-nil, it identifies the language that PATTERNS should be applied to. If LANG-SYMBOL is nil, PATTERNS are applied to the current buffer, and are prioritized over language-specific patterns. Either way, PATTERNS are prioritized over `tree-sitter-hl-default-patterns'. This function should be used by minor modes and configuration code. Major modes should set `tree-sitter-hl-default-patterns' instead. (fn LANG-SYMBOL PATTERNS) (defalias 'tree-sitter-hl-add-patterns #[514 "\203 \300\"\207\301!\207" [tree-sitter-hl--add-patterns-for-language tree-sitter-hl--add-patterns-locally] 5 (#$ . 8944)]) (byte-code "\300\301\302\303#\300\207" [function-put tree-sitter-hl-add-patterns lisp-indent-function 1] 4) #@168 Add buffer-local syntax highlighting PATTERNS. These will take precedence over `tree-sitter-hl-default-patterns', as well as previously added patterns. (fn PATTERNS) (defalias 'tree-sitter-hl--add-patterns-locally #[257 "\211@\232?\2059 \304C\305\"\"\306\n\2057\307C\310\311$\216\312 \210\211\306\240\210)\210\313\303!\2057 \2057\314 \266\202\207" [tree-sitter-hl--extra-patterns-list tree-sitter-hl--query tree-sitter-language tree-sitter-hl-mode append remove nil t make-closure #[0 "\302\242\205\n\301\300\211\207" [V0 V1 V2 tree-sitter-hl--query tree-sitter-hl--extra-patterns-list] 2] tree-sitter-hl--ensure-query boundp tree-sitter-hl--invalidate] 9 (#$ . 9723)]) #@140 Add syntax highlighting PATTERNS for the language identified by LANG-SYMBOL. See `tree-sitter-hl-add-patterns'. (fn LANG-SYMBOL PATTERNS) (defalias 'tree-sitter-hl--add-patterns-for-language #[514 "\301\"@\232?\205G\302\303!\"\210\3041,\305\306C\307\"\"\310$0\202E\210\311\306C\307\"\"#\306C\307\"\"\262\207" [tree-sitter-hl--patterns-alist alist-get tsc-make-query tree-sitter-require (map-not-inplace) map-put! append remove nil map-insert] 12 (#$ . 10418)]) (defvar tree-sitter-hl--query-cursor nil nil) (make-variable-buffer-local 'tree-sitter-hl--query-cursor) #@60 The max size delta of the (structurally) extended regions. (defconst tree-sitter-hl--extend-region-limit 2048 (#$ . 11022)) #@178 The max number of levels to walk up the syntax tree to extend the regions. The assumption is that: in any syntax highlighting pattern, the captures do not lie deeper than this. (defconst tree-sitter-hl--extend-region-levels 4 (#$ . 11153)) #@1104 Extend HL-REGION and QUERY-REGION before highlighting, mutably. For performance reason, we execute the highlighting query on a region, instead of on the whole buffer. When range restriction is used, a match is returned only when all nodes in a pattern intersect the query cursor's range. Therefore, QUERY-REGION should intersect all relevant nodes, not just nodes to be highlighted. One case that illustrates the need for QUERY-REGION to be larger than HL-REGION is when `evil-adjust-cursor' triggers a `vertical-motion' (outside of a redisplay), resulting in `jit-lock--run-funtions' being called on a very small region. Another case is sibling sub-patterns being cut in halves by HL-REGION's boundaries. Note that the main performance bottleneck with querying the whole buffer is in accessing nodes' texts, which involves allocating temporary strings, copying them to the dynamic modules, then garbage-collecting them. When dynamic modules have direct access to buffer text, this function may become obsolete. See https://github.com/tree-sitter/tree-sitter/issues/598. (fn HL-REGION QUERY-REGION) (defalias 'tree-sitter-hl--extend-regions #[514 "\303!\242\243\211Z\304#\305!\211\242\243\211Z\211Z\306 W\2033\240\210\241\210\203z W\203z\240\210\241\210\211T\211\262\nX\205V\307 !\211\262\n\2033\305 !\211\211@\262\211A\262\210Z\262 Z\262\210\2023@b\210\310\306!\240\210Ab\210\310\311!\241\207" [tree-sitter-tree tree-sitter-hl--extend-region-limit tree-sitter-hl--extend-region-levels tsc-root-node tsc-get-descendant-for-position-range tsc-node-position-range 0 tsc-get-parent line-beginning-position 2] 20 (#$ . 11401)]) #@231 Append VALUE to PROP of the text from START to END. This is similar to `font-lock-append-text-property', but deduplicates values. It also expects VALUE to be a single value, not a list. (fn START END PROP VALUE &optional OBJECT) (defalias 'tree-sitter-hl--append-text-property #[1284 "\300\211U?\205a\301 $\262\302#\262\303>\203<\211<\203<\304@!\2048\211@\305>\203<\211C\262\211<\204E\211C\262>\204[\306\307 C\"%\210\262\202\207" [nil next-single-property-change get-text-property (face font-lock-face) keywordp (foreground-color background-color) put-text-property append] 14 (#$ . 13095)]) #@233 Prepend VALUE to PROP of the text from START to END. This is similar to `font-lock-prepend-text-property', but deduplicates values. It also expects VALUE to be a single value, not a list. (fn START END PROP VALUE &optional OBJECT) (defalias 'tree-sitter-hl--prepend-text-property #[1284 "\300\211U?\205_\301 $\262\302#\262\303>\203<\211<\203<\304@!\2048\211@\305>\203<\211C\262\211<\204E\211C\262>\204Y\306B%\210\262\202\207" [nil next-single-property-change get-text-property (face font-lock-face) keywordp (foreground-color background-color) put-text-property] 13 (#$ . 13738)]) #@44 Highlight the given CAPTURE. (fn CAPTURE) (defalias 'tree-sitter-hl--highlight-capture #[257 "\211\242\243\211\242\243\300!\205\301\302!\302!\303$\207" [facep tree-sitter-hl--append-text-property byte-to-position face] 13 (#$ . 14370)]) #@206 Highlight the region (BEG . END). This is intended to be used as a buffer-local override of `font-lock-fontify-region-function'. If LOUDLY is non-nil, print debug messages. (fn BEG END &optional LOUDLY) (defalias 'tree-sitter-hl--highlight-region #[770 "\212\214~\210\306BB\307\"\210\211@\262\211A\262\210\310 \311@!\311A!#\266\312\n!\313 \314$\315 \306\211\306\316\317\"\216\320\"\210\321\322\"\210\203^\203^\323#\210,\210\324BB\266\202+\207" [inhibit-point-motion-hooks tree-sitter-hl--query-cursor tree-sitter-tree tree-sitter-hl--query buffer-undo-list inhibit-read-only t tree-sitter-hl--extend-regions tsc--query-cursor-set-byte-range position-bytes tsc-root-node tsc--query-cursor-captures-1 tsc--buffer-substring-no-properties buffer-modified-p make-closure #[0 "\300?\205\301\302!\207" [V0 restore-buffer-modified-p nil] 2] font-lock-unfontify-region mapc tree-sitter-hl--highlight-capture font-lock-fontify-keywords-region jit-lock-bounds inhibit-modification-hooks tree-sitter-hl-use-font-lock-keywords font-lock-set-defaults] 11 (#$ . 14627)]) #@178 Mark regions of text to be rehighlighted after a text change. Installed on `tree-sitter-after-change-functions'. OLD-TREE is the tree before the edit. (fn &optional OLD-TREE) (defalias 'tree-sitter-hl--invalidate #[256 "\211\203\f\301\302\303\"\"\207\304 \207" [tree-sitter-tree seq-do #[257 "\300!\210\211G\301H\302H\303!\303!\304\"\207" [vectorp 0 1 byte-to-position font-lock-flush] 11 "\n\n(fn RANGE)"] tsc-changed-ranges font-lock-flush] 6 (#$ . 15733)]) (defvar tree-sitter-hl--font-lock-keywords nil nil) (make-variable-buffer-local 'tree-sitter-hl--font-lock-keywords) #@72 Remove keywords set by `font-lock-defaults' from `font-lock-keywords'. (defalias 'tree-sitter-hl--minimize-font-lock-keywords #[0 "\205= ?\205=\n \305=\205=\f@\211<\203\"\211@9\203\"\211\202$\211C\211\211\2059\211@\306\307\310!\"\210A\266\202\202%\262\266\202\207" [font-lock-set-defaults tree-sitter-hl--font-lock-keywords font-lock-keywords tree-sitter-hl-use-font-lock-keywords font-lock-defaults :except-font-lock-defaults font-lock-remove-keywords nil font-lock-eval-keywords] 8 (#$ . 16330)]) #@70 Undo the hack done by `tree-sitter-hl--minimize-font-lock-keywords'. (defalias 'tree-sitter-hl--restore-font-lock-keywords #[0 "\205 \205 \303\211\207" [font-lock-set-defaults tree-sitter-hl--font-lock-keywords font-lock-keywords nil] 2 (#$ . 16848)]) #@128 Set up `tree-sitter-hl' in the current buffer. This assumes both `tree-sitter-mode' and `font-lock-mode' were already enabled. (defalias 'tree-sitter-hl--setup #[0 "\301 \205!\204\302 \303 \210\304\305\303\306\307$\210\310\311\312\313B\314\306$\210\315 \207" [tree-sitter-hl--query-cursor tree-sitter-hl--ensure-query tsc-make-query-cursor tree-sitter-hl--invalidate add-hook tree-sitter-after-change-functions nil :local advice--add-function :override #[0 "\300\301!\207" [advice--buffer-local font-lock-fontify-region-function] 2] #[257 "\300\301\"\207" [advice--set-buffer-local font-lock-fontify-region-function] 4 "\n\n(fn GV--VAL)"] tree-sitter-hl--highlight-region tree-sitter-hl--minimize-font-lock-keywords] 5 (#$ . 17114)]) #@51 Tear down `tree-sitter-hl' in the current buffer. (defalias 'tree-sitter-hl--teardown #[0 "\302\303\304!\305\"\211\303\304!=\204\306\304\"\210\210\307\310\311\312#\210\203#\313\314 \210 \205+\313\315 \207" [tree-sitter-hl--query-cursor tree-sitter-hl--query advice--remove-function advice--buffer-local font-lock-fontify-region-function tree-sitter-hl--highlight-region advice--set-buffer-local remove-hook tree-sitter-after-change-functions tree-sitter-hl--invalidate :local nil font-lock-flush tree-sitter-hl--restore-font-lock-keywords] 4 (#$ . 17860)]) #@107 Non-nil if Tree-Sitter-Hl mode is enabled. Use the command `tree-sitter-hl-mode' to change this variable. (defvar tree-sitter-hl-mode nil (#$ . 18432)) (make-variable-buffer-local 'tree-sitter-hl-mode) #@955 Toggle syntax highlighting based on Tree-sitter's syntax tree. If `tree-sitter-hl-default-patterns' is nil, turning on this mode does nothing, and does not interfere with `font-lock-mode'. This is a minor mode. If called interactively, toggle the `Tree-Sitter-Hl mode' mode. If the prefix argument is positive, enable the mode, and if it is zero or negative, disable the mode. If called from Lisp, toggle the mode if ARG is `toggle'. Enable the mode if ARG is nil, omitted, or is a positive number. Disable the mode if ARG is a negative number. To check whether the minor mode is enabled in the current buffer, evaluate `tree-sitter-hl-mode'. The mode's hook is called both when the mode is enabled and when it is disabled. Enabling this automatically enables `tree-sitter-mode' in the buffer. To enable this automatically whenever `tree-sitter-mode' is enabled: (add-hook 'tree-sitter-after-on-hook #'tree-sitter-hl-mode) (fn &optional ARG) (defalias 'tree-sitter-hl-mode #[256 "\303 \304=\203 ?\202\247\203\305W\203\306\202\307\310\301!\2031\311\300 \"\2031\300 B\203V\307C\312\313\"\216\n\204C\302 \210\314 \210\211\306\240\210)\210\315\316\317\306\320$\210\202Y\321 \210\322\323\203c\324\202d\325\"\210\326\327!\203\206\303 \203x\211\303 \232\203\206\330\331\203\202\332\202\203\333\334#\210\210\335 \210\207" [tree-sitter-hl-mode local-minor-modes tree-sitter-mode current-message toggle 1 nil t boundp delq make-closure #[0 "\300\242\205 \302\303 \207" [V0 tree-sitter-hl-mode nil tree-sitter-hl--teardown] 1] tree-sitter-hl--setup add-hook tree-sitter--before-off-hook (lambda nil (tree-sitter-hl-mode -1)) :local tree-sitter-hl--teardown run-hooks tree-sitter-hl-mode-hook tree-sitter-hl-mode-on-hook tree-sitter-hl-mode-off-hook called-interactively-p any message "Tree-Sitter-Hl mode %sabled%s" "en" "dis" " in current buffer" force-mode-line-update] 7 (#$ . 18641) (byte-code "\203\n\301!\202 \302C\207" [current-prefix-arg prefix-numeric-value toggle] 2)]) (defvar tree-sitter-hl-mode-hook nil) (byte-code "\301\302N\204\f\303\301\302\304#\210\303\301\305\306#\210\303\301\307\310C#\210\311\312\310\313\300!\205#\310\211%\210\314\315!\207" [tree-sitter-hl-mode-map tree-sitter-hl-mode-hook variable-documentation put "Hook run after entering or leaving `tree-sitter-hl-mode'.\nNo problems result if this variable is not bound.\n`add-hook' automatically binds it. (This is true for all hook variables.)" custom-type hook standard-value nil add-minor-mode tree-sitter-hl-mode boundp provide tree-sitter-hl] 6)