summaryrefslogtreecommitdiff
path: root/lisp/progmodes/go-ts-mode.el
diff options
context:
space:
mode:
authorEli Zaretskii <eliz@gnu.org>2023-01-20 10:28:26 +0200
committerEli Zaretskii <eliz@gnu.org>2023-01-20 10:28:26 +0200
commit6b2f85caa6cae1178b8abee531b0b9b0cf618a00 (patch)
tree9a7768513e40f700cf7c9f587ad117f058f6b56e /lisp/progmodes/go-ts-mode.el
parentb56cf28b325c927d5e51173b00f5e5354ba62def (diff)
downloademacs-6b2f85caa6cae1178b8abee531b0b9b0cf618a00.tar.gz
emacs-6b2f85caa6cae1178b8abee531b0b9b0cf618a00.tar.bz2
emacs-6b2f85caa6cae1178b8abee531b0b9b0cf618a00.zip
Make tree-sitter based modes optional
* lisp/progmodes/c-ts-mode.el: Update Commentary. Make 'auto-mode-alist' update conditional on the tree-sitter and grammar libraries being available. * lisp/progmodes/cmake-ts-mode.el: * lisp/progmodes/csharp-mode.el: * lisp/progmodes/dockerfile-ts-mode.el: * lisp/progmodes/go-ts-mode.el: * lisp/progmodes/java-ts-mode.el: * lisp/progmodes/js.el: * lisp/progmodes/json-ts-mode.el: * lisp/progmodes/python.el: * lisp/progmodes/ruby-ts-mode.el: * lisp/progmodes/typescript-ts-mode.el: * lisp/textmodes/css-mode.el: * lisp/textmodes/toml-ts-mode.el: * lisp/textmodes/yaml-ts-mode.el: Make 'auto-mode-alist' update for tree-sitter based modes be conditional on the tree-sitter and grammar libraries being available. (Bug#60559)
Diffstat (limited to 'lisp/progmodes/go-ts-mode.el')
-rw-r--r--lisp/progmodes/go-ts-mode.el12
1 files changed, 6 insertions, 6 deletions
diff --git a/lisp/progmodes/go-ts-mode.el b/lisp/progmodes/go-ts-mode.el
index 64e761d2f72..d552e1360e0 100644
--- a/lisp/progmodes/go-ts-mode.el
+++ b/lisp/progmodes/go-ts-mode.el
@@ -175,9 +175,6 @@
"Tree-sitter font-lock settings for `go-ts-mode'.")
;;;###autoload
-(add-to-list 'auto-mode-alist '("\\.go\\'" . go-ts-mode))
-
-;;;###autoload
(define-derived-mode go-ts-mode prog-mode "Go"
"Major mode for editing Go, powered by tree-sitter."
:group 'go
@@ -226,6 +223,9 @@
(treesit-major-mode-setup)))
+(if (treesit-ready-p 'go)
+ (add-to-list 'auto-mode-alist '("\\.go\\'" . go-ts-mode)))
+
(defun go-ts-mode--defun-name (node)
"Return the defun name of NODE.
Return nil if there is no name or if NODE is not a defun node."
@@ -346,9 +346,6 @@ what the parent of the node would be if it were a node."
"Tree-sitter font-lock settings for `go-mod-ts-mode'.")
;;;###autoload
-(add-to-list 'auto-mode-alist '("/go\\.mod\\'" . go-mod-ts-mode))
-
-;;;###autoload
(define-derived-mode go-mod-ts-mode prog-mode "Go Mod"
"Major mode for editing go.mod files, powered by tree-sitter."
:group 'go
@@ -376,6 +373,9 @@ what the parent of the node would be if it were a node."
(treesit-major-mode-setup)))
+(if (treesit-ready-p 'gomod)
+ (add-to-list 'auto-mode-alist '("/go\\.mod\\'" . go-mod-ts-mode)))
+
(provide 'go-ts-mode)
;;; go-ts-mode.el ends here