aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVincenzo Pupillo2024-11-07 12:55:50 +0100
committerEli Zaretskii2024-11-14 10:47:51 +0200
commitf69f54c454eb3c0f8ff8c55cfd2b7832ea1709cf (patch)
tree67b3e795b8b7cb51bb13146488a0307bd6058c11
parent27aacbd172f3b94926073250ef81a226616d1e45 (diff)
downloademacs-f69f54c454eb3c0f8ff8c55cfd2b7832ea1709cf.tar.gz
emacs-f69f54c454eb3c0f8ff8c55cfd2b7832ea1709cf.zip
Improve font-locking and indentation in 'php-ts-mode'
* lisp/progmodes/php-ts-mode.el (php-ts-mode--language-source-alist): Updated to latest version of PHP grammar. (php-ts-mode--indent-styles): 'namespace_use_declaration' is now correctly indented. (php-ts-mode--operators): Support of the "argument unpacking operator". (php-ts-mode--font-lock-settings): 'nullsafe_member_call_expression' is now highlighted correctly. (php-ts-mode--comment-indent-new-line): Delete trailing whitespace before inserting newline (see bug#73900 for more information). Bug#74239
-rw-r--r--lisp/progmodes/php-ts-mode.el17
1 files changed, 12 insertions, 5 deletions
diff --git a/lisp/progmodes/php-ts-mode.el b/lisp/progmodes/php-ts-mode.el
index 14a487d3f7a..d8a3f60508b 100644
--- a/lisp/progmodes/php-ts-mode.el
+++ b/lisp/progmodes/php-ts-mode.el
@@ -84,7 +84,7 @@
84 84
85;;; Install treesitter language parsers 85;;; Install treesitter language parsers
86(defvar php-ts-mode--language-source-alist 86(defvar php-ts-mode--language-source-alist
87 '((php . ("https://github.com/tree-sitter/tree-sitter-php" "v0.23.4" "php/src")) 87 '((php . ("https://github.com/tree-sitter/tree-sitter-php" "v0.23.5" "php/src"))
88 (phpdoc . ("https://github.com/claytonrcarter/tree-sitter-phpdoc")) 88 (phpdoc . ("https://github.com/claytonrcarter/tree-sitter-phpdoc"))
89 (html . ("https://github.com/tree-sitter/tree-sitter-html" "v0.23.0")) 89 (html . ("https://github.com/tree-sitter/tree-sitter-html" "v0.23.0"))
90 (javascript . ("https://github.com/tree-sitter/tree-sitter-javascript" "v0.23.0")) 90 (javascript . ("https://github.com/tree-sitter/tree-sitter-javascript" "v0.23.0"))
@@ -640,6 +640,7 @@ characters of the current line."
640 ((query "(class_interface_clause (qualified_name) @indent)") 640 ((query "(class_interface_clause (qualified_name) @indent)")
641 parent-bol php-ts-mode-indent-offset) 641 parent-bol php-ts-mode-indent-offset)
642 ((parent-is "class_declaration") parent-bol 0) 642 ((parent-is "class_declaration") parent-bol 0)
643 ((parent-is "namespace_use_declaration") parent-bol php-ts-mode-indent-offset)
643 ((parent-is "namespace_use_group") parent-bol php-ts-mode-indent-offset) 644 ((parent-is "namespace_use_group") parent-bol php-ts-mode-indent-offset)
644 ((parent-is "function_definition") parent-bol 0) 645 ((parent-is "function_definition") parent-bol 0)
645 ((parent-is "member_call_expression") first-sibling php-ts-mode-indent-offset) 646 ((parent-is "member_call_expression") first-sibling php-ts-mode-indent-offset)
@@ -781,7 +782,7 @@ characters of the current line."
781 '("--" "**=" "*=" "/=" "%=" "+=" "-=" ".=" "<<=" ">>=" "&=" "^=" 782 '("--" "**=" "*=" "/=" "%=" "+=" "-=" ".=" "<<=" ">>=" "&=" "^="
782 "|=" "??" "??=" "||" "&&" "|" "^" "&" "==" "!=" "<>" "===" "!==" 783 "|=" "??" "??=" "||" "&&" "|" "^" "&" "==" "!=" "<>" "===" "!=="
783 "<" ">" "<=" ">=" "<=>" "<<" ">>" "+" "-" "." "*" "**" "/" "%" 784 "<" ">" "<=" ">=" "<=>" "<<" ">>" "+" "-" "." "*" "**" "/" "%"
784 "->" "?->") 785 "->" "?->" "...")
785 "PHP operators for tree-sitter font-locking.") 786 "PHP operators for tree-sitter font-locking.")
786 787
787(defconst php-ts-mode--predefined-constant 788(defconst php-ts-mode--predefined-constant
@@ -993,7 +994,7 @@ characters of the current line."
993 (member_call_expression 994 (member_call_expression
994 name: (_) @font-lock-function-call-face) 995 name: (_) @font-lock-function-call-face)
995 (nullsafe_member_call_expression 996 (nullsafe_member_call_expression
996 name: (_) @font-lock-constant-face)) 997 name: (_) @font-lock-function-call-face))
997 998
998 :language 'php 999 :language 'php
999 :feature 'argument 1000 :feature 'argument
@@ -1266,8 +1267,14 @@ less common PHP-style # comment. SOFT works the same as in
1266 (line-end-position) 1267 (line-end-position)
1267 t nil)) 1268 t nil))
1268 (let ((offset (- (match-beginning 0) (line-beginning-position))) 1269 (let ((offset (- (match-beginning 0) (line-beginning-position)))
1269 (comment-prefix (match-string 0))) 1270 (comment-prefix (match-string 0))
1270 (if soft (insert-and-inherit ?\n) (newline 1)) 1271 (insert-line-break
1272 (lambda ()
1273 (delete-horizontal-space)
1274 (if soft
1275 (insert-and-inherit ?\n)
1276 (newline 1)))))
1277 (funcall insert-line-break)
1271 (delete-region (line-beginning-position) (point)) 1278 (delete-region (line-beginning-position) (point))
1272 (insert 1279 (insert
1273 (make-string offset ?\s) 1280 (make-string offset ?\s)