summaryrefslogtreecommitdiff
path: root/lisp/progmodes/go-ts-mode.el
diff options
context:
space:
mode:
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