[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
emacs-29 eaf25b9c6ae: go-ts-mode: Use iota query only if supported (Bug#
From: |
Dmitry Gutov |
Subject: |
emacs-29 eaf25b9c6ae: go-ts-mode: Use iota query only if supported (Bug#63086) |
Date: |
Wed, 3 May 2023 17:56:57 -0400 (EDT) |
branch: emacs-29
commit eaf25b9c6ae4020f76a810b6920b65613ca50e5d
Author: Randy Taylor <dev@rjt.dev>
Commit: Dmitry Gutov <dmitry@gutov.dev>
go-ts-mode: Use iota query only if supported (Bug#63086)
iota query support was added on January 5, 2022. To support older
versions of the tree-sitter-go grammar (like the latest tagged version,
v0.19.1, which was released on March 3, 2021), check if the query is
supported before trying to use it.
* lisp/progmodes/go-ts-mode.el (go-ts-mode--iota-query-supported-p): New
function.
(go-ts-mode--font-lock-settings): Use it.
---
lisp/progmodes/go-ts-mode.el | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/lisp/progmodes/go-ts-mode.el b/lisp/progmodes/go-ts-mode.el
index 77c97ffac11..f32a2d75775 100644
--- a/lisp/progmodes/go-ts-mode.el
+++ b/lisp/progmodes/go-ts-mode.el
@@ -105,6 +105,12 @@
">>" "%=" ">>=" "--" "!" "..." "&^" "&^=" "~")
"Go operators for tree-sitter font-locking.")
+(defun go-ts-mode--iota-query-supported-p ()
+ "Returns t if the iota query is supported by the current version of
+the tree-sitter-go grammar."
+ (ignore-errors
+ (or (treesit-query-string "" '((iota) @font-lock-constant-face) 'go) t)))
+
(defvar go-ts-mode--font-lock-settings
(treesit-font-lock-rules
:language 'go
@@ -117,7 +123,9 @@
:language 'go
:feature 'constant
- '([(false) (iota) (nil) (true)] @font-lock-constant-face
+ `([(false) (nil) (true)] @font-lock-constant-face
+ ,@(when (go-ts-mode--iota-query-supported-p)
+ '((iota) @font-lock-constant-face))
(const_declaration
(const_spec name: (identifier) @font-lock-constant-face)))
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- emacs-29 eaf25b9c6ae: go-ts-mode: Use iota query only if supported (Bug#63086),
Dmitry Gutov <=