unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Vincenzo Pupillo <v.pupillo@gmail.com>
To: 74239@debbugs.gnu.org
Subject: bug#74239: 30.0.92; php-ts-mode: Some fixes for indentation and syntax highlighting.
Date: Thu, 07 Nov 2024 15:23:03 +0100	[thread overview]
Message-ID: <9805172.eNJFYEL58v@3-191.divsi.unimi.it> (raw)

[-- Attachment #1: Type: text/plain, Size: 170 bytes --]

Hi, 
this patch fixes some issues with both indentation and syntax highlighting.
Has been tested with both the latest and earlier versions of the grammar.

Thank you.

V.

[-- Attachment #2: 0001-Improved-font-locking-and-indentation.patch --]
[-- Type: text/x-patch, Size: 3391 bytes --]

From 693e78567f481a9749ddf8db7a3e144245bac102 Mon Sep 17 00:00:00 2001
From: Vincenzo Pupillo <v.pupillo@gmail.com>
Date: Thu, 7 Nov 2024 12:55:50 +0100
Subject: [PATCH] Improved font-locking and indentation.

* 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).
---
 lisp/progmodes/php-ts-mode.el | 17 ++++++++++++-----
 1 file 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 @@
 
 ;;; Install treesitter language parsers
 (defvar php-ts-mode--language-source-alist
-  '((php . ("https://github.com/tree-sitter/tree-sitter-php" "v0.23.4" "php/src"))
+  '((php . ("https://github.com/tree-sitter/tree-sitter-php" "v0.23.5" "php/src"))
     (phpdoc . ("https://github.com/claytonrcarter/tree-sitter-phpdoc"))
     (html . ("https://github.com/tree-sitter/tree-sitter-html"  "v0.23.0"))
     (javascript . ("https://github.com/tree-sitter/tree-sitter-javascript" "v0.23.0"))
@@ -640,6 +640,7 @@ php-ts-mode--indent-styles
            ((query "(class_interface_clause (qualified_name) @indent)")
             parent-bol php-ts-mode-indent-offset)
            ((parent-is "class_declaration") parent-bol 0)
+	   ((parent-is "namespace_use_declaration") parent-bol php-ts-mode-indent-offset)
            ((parent-is "namespace_use_group") parent-bol php-ts-mode-indent-offset)
            ((parent-is "function_definition") parent-bol 0)
            ((parent-is "member_call_expression") first-sibling php-ts-mode-indent-offset)
@@ -781,7 +782,7 @@ php-ts-mode--operators
   '("--" "**=" "*=" "/=" "%=" "+=" "-=" ".=" "<<=" ">>=" "&=" "^="
     "|=" "??"  "??=" "||" "&&" "|" "^" "&" "==" "!=" "<>" "===" "!=="
     "<" ">" "<=" ">=" "<=>" "<<" ">>" "+" "-" "." "*" "**" "/" "%"
-    "->" "?->")
+    "->" "?->" "...")
   "PHP operators for tree-sitter font-locking.")
 
 (defconst php-ts-mode--predefined-constant
@@ -993,7 +994,7 @@ php-ts-mode--font-lock-settings
      (member_call_expression
       name: (_) @font-lock-function-call-face)
      (nullsafe_member_call_expression
-      name: (_) @font-lock-constant-face))
+      name: (_) @font-lock-function-call-face))
 
    :language 'php
    :feature 'argument
@@ -1266,8 +1267,14 @@ php-ts-mode--comment-indent-new-line
          (line-end-position)
          t nil))
       (let ((offset (- (match-beginning 0) (line-beginning-position)))
-            (comment-prefix (match-string 0)))
-        (if soft (insert-and-inherit ?\n) (newline 1))
+            (comment-prefix (match-string 0))
+	    (insert-line-break
+             (lambda ()
+	       (delete-horizontal-space)
+	       (if soft
+		   (insert-and-inherit ?\n)
+		 (newline  1)))))
+	(funcall insert-line-break)
         (delete-region (line-beginning-position) (point))
         (insert
          (make-string offset ?\s)
-- 
2.47.0


             reply	other threads:[~2024-11-07 14:23 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-07 14:23 Vincenzo Pupillo [this message]
2024-11-14  8:50 ` bug#74239: 30.0.92; php-ts-mode: Some fixes for indentation and syntax highlighting Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9805172.eNJFYEL58v@3-191.divsi.unimi.it \
    --to=v.pupillo@gmail.com \
    --cc=74239@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).