mirror of
https://github.com/masscollaborationlabs/emacs.git
synced 2025-07-08 21:29:37 +00:00
Fix incompatibility with tree-sitter-javascript >= 0.20.2
Starting from version 0.20.2 the grammar's primary expression "function" has been renamed to "function_expression". A new function checks if the new primary expression is available, and if so, it returns the correct rules. * lisp/progmodes/js.el (js--treesit-font-lock-compatibility-definition-feature): New function. (js--treesit-font-lock-settings): Use it. (Bug#68879)
This commit is contained in:
parent
d49124fc14
commit
2f69353e4a
1 changed files with 21 additions and 6 deletions
|
@ -3427,6 +3427,26 @@ This function is intended for use in `after-change-functions'."
|
||||||
|
|
||||||
;;; Tree sitter integration
|
;;; Tree sitter integration
|
||||||
|
|
||||||
|
(defun js--treesit-font-lock-compatibility-definition-feature ()
|
||||||
|
"Font lock helper, to handle different releases of tree-sitter-javascript.
|
||||||
|
Check if a node type is available, then return the right font lock rules
|
||||||
|
for \"definition\" feature."
|
||||||
|
(condition-case nil
|
||||||
|
(progn (treesit-query-capture 'javascript '((function_expression) @cap))
|
||||||
|
;; starting from 0.20.2
|
||||||
|
'((function_expression
|
||||||
|
name: (identifier) @font-lock-function-name-face)
|
||||||
|
(variable_declarator
|
||||||
|
name: (identifier) @font-lock-function-name-face
|
||||||
|
value: [(function_expression) (arrow_function)])))
|
||||||
|
(error
|
||||||
|
;; older version
|
||||||
|
'((function
|
||||||
|
name: (identifier) @font-lock-function-name-face)
|
||||||
|
(variable_declarator
|
||||||
|
name: (identifier) @font-lock-function-name-face
|
||||||
|
value: [(function) (arrow_function)])))))
|
||||||
|
|
||||||
(defun js-jsx--treesit-indent-compatibility-bb1f97b ()
|
(defun js-jsx--treesit-indent-compatibility-bb1f97b ()
|
||||||
"Indent rules helper, to handle different releases of tree-sitter-javascript.
|
"Indent rules helper, to handle different releases of tree-sitter-javascript.
|
||||||
Check if a node type is available, then return the right indent rules."
|
Check if a node type is available, then return the right indent rules."
|
||||||
|
@ -3538,8 +3558,7 @@ Check if a node type is available, then return the right indent rules."
|
||||||
|
|
||||||
:language 'javascript
|
:language 'javascript
|
||||||
:feature 'definition
|
:feature 'definition
|
||||||
'((function
|
`(,@(js--treesit-font-lock-compatibility-definition-feature)
|
||||||
name: (identifier) @font-lock-function-name-face)
|
|
||||||
|
|
||||||
(class_declaration
|
(class_declaration
|
||||||
name: (identifier) @font-lock-type-face)
|
name: (identifier) @font-lock-type-face)
|
||||||
|
@ -3558,10 +3577,6 @@ Check if a node type is available, then return the right indent rules."
|
||||||
(variable_declarator
|
(variable_declarator
|
||||||
name: (identifier) @font-lock-variable-name-face)
|
name: (identifier) @font-lock-variable-name-face)
|
||||||
|
|
||||||
(variable_declarator
|
|
||||||
name: (identifier) @font-lock-function-name-face
|
|
||||||
value: [(function) (arrow_function)])
|
|
||||||
|
|
||||||
(variable_declarator
|
(variable_declarator
|
||||||
name: [(array_pattern (identifier) @font-lock-variable-name-face)
|
name: [(array_pattern (identifier) @font-lock-variable-name-face)
|
||||||
(object_pattern
|
(object_pattern
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue