all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#70296: 29.3.50 ; [PATCH] Update go-ts-mode to support latest go grammar
@ 2024-04-09  3:24 Yuan Fu
  2024-04-09 23:16 ` Randy Taylor
  0 siblings, 1 reply; 3+ messages in thread
From: Yuan Fu @ 2024-04-09  3:24 UTC (permalink / raw)
  To: 70296; +Cc: dev

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

X-Debbugs-CC: dev@rjt.dev

tree-sitter-go changed method_spec to method_elem in
https://github.com/tree-sitter/tree-sitter-go/commit/b82ab803d887002a0af11f6ce63d72884580bf33

so now go-ts-mode breaks on the lastest go grammar. This patch should restore peace to go-ts-mode.

Yuan


[-- Attachment #2: go-ts-mode-method.patch --]
[-- Type: application/octet-stream, Size: 2066 bytes --]

From 07adcafc91b5d7249dcd79a20d4306bf103713fe Mon Sep 17 00:00:00 2001
From: Yuan Fu <casouri@gmail.com>
Date: Mon, 8 Apr 2024 20:20:25 -0700
Subject: [PATCH] Update go-ts-mode to support latest tree-sitter-go grammar

tree-sitter-go changed method_spec to method_elem in
https://github.com/tree-sitter/tree-sitter-go/commit/b82ab803d887002a0af11f6ce63d72884580bf33

* lisp/progmodes/go-ts-mode.el:
(go-ts-mode--method-elem-supported-p): New function.
(go-ts-mode--font-lock-settings): Conditionally use method_elem or
method_spec in the query.
---
 lisp/progmodes/go-ts-mode.el | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/lisp/progmodes/go-ts-mode.el b/lisp/progmodes/go-ts-mode.el
index e8a176e3d9d..a5b49bd8313 100644
--- a/lisp/progmodes/go-ts-mode.el
+++ b/lisp/progmodes/go-ts-mode.el
@@ -112,6 +112,13 @@ go-ts-mode--iota-query-supported-p
   (ignore-errors
     (or (treesit-query-string "" '((iota) @font-lock-constant-face) 'go) t)))
 
+;; tree-sitter-go changed method_spec to method_elem in
+;; https://github.com/tree-sitter/tree-sitter-go/commit/b82ab803d887002a0af11f6ce63d72884580bf33
+(defun go-ts-mode--method-elem-supported-p ()
+  "Return t if Go grammar uses `method_elem' instead of `method_spec'."
+  (ignore-errors
+    (or (treesit-query-string "" '((method_elem) @cap) 'go) t)))
+
 (defvar go-ts-mode--font-lock-settings
   (treesit-font-lock-rules
    :language 'go
@@ -136,11 +143,13 @@ go-ts-mode--font-lock-settings
 
    :language 'go
    :feature 'definition
-   '((function_declaration
+   `((function_declaration
       name: (identifier) @font-lock-function-name-face)
      (method_declaration
       name: (field_identifier) @font-lock-function-name-face)
-     (method_spec
+     (,(if (go-ts-mode--method-elem-supported-p)
+           'method_elem
+         'method_spec)
       name: (field_identifier) @font-lock-function-name-face)
      (field_declaration
       name: (field_identifier) @font-lock-property-name-face)
-- 
2.41.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* bug#70296: 29.3.50 ; [PATCH] Update go-ts-mode to support latest go grammar
  2024-04-09  3:24 bug#70296: 29.3.50 ; [PATCH] Update go-ts-mode to support latest go grammar Yuan Fu
@ 2024-04-09 23:16 ` Randy Taylor
  2024-04-11  0:41   ` Randy Taylor
  0 siblings, 1 reply; 3+ messages in thread
From: Randy Taylor @ 2024-04-09 23:16 UTC (permalink / raw)
  To: Yuan Fu; +Cc: 70296

On Monday, April 8th, 2024 at 23:24, Yuan Fu <casouri@gmail.com> wrote:
> 
> 
> X-Debbugs-CC: dev@rjt.dev
> 
> tree-sitter-go changed method_spec to method_elem in
> https://github.com/tree-sitter/tree-sitter-go/commit/b82ab803d887002a0af11f6ce63d72884580bf33
> 
> so now go-ts-mode breaks on the lastest go grammar. This patch should restore peace to go-ts-mode.
> 
> Yuan

Looks good to me, thanks!





^ permalink raw reply	[flat|nested] 3+ messages in thread

* bug#70296: 29.3.50 ; [PATCH] Update go-ts-mode to support latest go grammar
  2024-04-09 23:16 ` Randy Taylor
@ 2024-04-11  0:41   ` Randy Taylor
  0 siblings, 0 replies; 3+ messages in thread
From: Randy Taylor @ 2024-04-11  0:41 UTC (permalink / raw)
  To: Yuan Fu; +Cc: 70296-done@debbugs.gnu.org

Closing as this was installed on emacs-29.





^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-04-11  0:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-09  3:24 bug#70296: 29.3.50 ; [PATCH] Update go-ts-mode to support latest go grammar Yuan Fu
2024-04-09 23:16 ` Randy Taylor
2024-04-11  0:41   ` Randy Taylor

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.