[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/go-mode 4b02fb811c 1/3: Add go-dot-work-mode for editing g
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/go-mode 4b02fb811c 1/3: Add go-dot-work-mode for editing go.work files |
Date: |
Tue, 26 Jul 2022 21:58:30 -0400 (EDT) |
branch: elpa/go-mode
commit 4b02fb811c359cf946ea35324e2b29214f8d5810
Author: Jimmy Yuen Ho Wong <wyuenho@gmail.com>
Commit: Dominik Honnef <dominik@honnef.co>
Add go-dot-work-mode for editing go.work files
Closes: gh-408 [via git-merge-pr]
---
go-mode.el | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/go-mode.el b/go-mode.el
index cdebdc3cae..b40203039f 100644
--- a/go-mode.el
+++ b/go-mode.el
@@ -2908,6 +2908,33 @@ If BUFFER, return the number of characters in that
buffer instead."
;;;###autoload
(add-to-list 'auto-mode-alist '("go\\.mod\\'" . go-dot-mod-mode))
+(defconst go-dot-work-mode-keywords
+ '("go" "replace" "use")
+ "All keywords for go.work files. Used for font locking.")
+
+;;;###autoload
+(define-derived-mode go-dot-work-mode fundamental-mode "Go Work"
+ "A major mode for editor go.work files."
+ :syntax-table go-dot-mod-mode-syntax-table
+ (set (make-local-variable 'comment-start) "// ")
+ (set (make-local-variable 'comment-end) "")
+ (set (make-local-variable 'comment-use-syntax) t)
+ (set (make-local-variable 'comment-start-skip) "\\(//+\\)\\s *")
+
+ (set (make-local-variable 'font-lock-defaults)
+ '(go-dot-work-mode-keywords))
+ (set (make-local-variable 'indent-line-function) 'go-mode-indent-line)
+
+ ;; Go style
+ (setq indent-tabs-mode t)
+
+ ;; we borrow the go-mode-indent function so we need this buffer cache
+ (set (make-local-variable 'go-dangling-cache) (make-hash-table :test 'eql))
+ (add-hook 'before-change-functions #'go--reset-dangling-cache-before-change
t t))
+
+;;;###autoload
+(add-to-list 'auto-mode-alist '("go\\.work\\'" . go-dot-work-mode))
+
;; The following functions were copied (and modified) from rust-mode.el.
;;
;; Copyright (c) 2015 The Rust Project Developers