[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/go-mode 8c884f3 292/495: Support goimports' new -srcdir fl
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/go-mode 8c884f3 292/495: Support goimports' new -srcdir flag |
Date: |
Sat, 7 Aug 2021 09:05:34 -0400 (EDT) |
branch: elpa/go-mode
commit 8c884f3d7c6673105669bb26066ece7df1527897
Author: Dominik Honnef <dominik@honnef.co>
Commit: Dominik Honnef <dominik@honnef.co>
Support goimports' new -srcdir flag
goimports, in order to support vendoring, needs to know where the source
file resides. Since we write the buffer's contents to a temporary file,
we need to tell goimports where the file came from.
We add a new customizable variable called gofmt-is-goimports. WHen it is
set to true, we use goimports' -srcdir flag.
---
NEWS | 8 ++++++++
go-mode.el | 16 ++++++++++++++--
2 files changed, 22 insertions(+), 2 deletions(-)
diff --git a/NEWS b/NEWS
index 4983edd..39320b3 100644
--- a/NEWS
+++ b/NEWS
@@ -23,6 +23,14 @@ go-mode-1.4.0 (???)
go-packages-native (the default) and go-packages-go-list are
provided.
+ * Add new variable gofmt-is-goimports. If gofmt-command is set to a
+ value that invokes goimports instead of gofmt, this variable needs
+ to be set to t. Otherwise, goimports will not be able to add
+ imports for vendored packages.
+
+ Setting it to t while not using goimports will break gofmt, as
+ gofmt doesn't support goimports' -srcdir flag.
+
go-mode-1.3.1 (2015-07-03)
* The 1.3.0 release forgot to update the version in the package
diff --git a/go-mode.el b/go-mode.el
index 3b2747e..ba9cc96 100644
--- a/go-mode.el
+++ b/go-mode.el
@@ -195,6 +195,12 @@ from https://github.com/bradfitz/goimports."
:type 'string
:group 'go)
+(defcustom gofmt-is-goimports nil
+ "Set to t if you use goimports. This is required to enable
+support for vendored packages."
+ :type 'boolean
+ :group 'go)
+
(defcustom gofmt-show-errors 'buffer
"Where to display gofmt error output.
It can either be displayed in its own buffer, in the echo area, or not at all.
@@ -1010,7 +1016,8 @@ with goflymake \(see URL
`https://github.com/dougm/goflymake'), gocode
(patchbuf (get-buffer-create "*Gofmt patch*"))
(errbuf (if gofmt-show-errors (get-buffer-create "*Gofmt Errors*")))
(coding-system-for-read 'utf-8)
- (coding-system-for-write 'utf-8))
+ (coding-system-for-write 'utf-8)
+ our-gofmt-args)
(unwind-protect
(save-restriction
@@ -1024,10 +1031,15 @@ with goflymake \(see URL
`https://github.com/dougm/goflymake'), gocode
(write-region nil nil tmpfile)
+ (when (and gofmt-is-goimports buffer-file-name)
+ (setq our-gofmt-args
+ (append our-gofmt-args
+ (list "-srcdir" (file-name-directory (file-truename
buffer-file-name))))))
+ (setq our-gofmt-args (append our-gofmt-args (list "-w" tmpfile)))
;; We're using errbuf for the mixed stdout and stderr output. This
;; is not an issue because gofmt -w does not produce any stdout
;; output in case of success.
- (if (zerop (call-process gofmt-command nil errbuf nil "-w" tmpfile))
+ (if (zerop (apply #'call-process gofmt-command nil errbuf nil
our-gofmt-args))
(progn
(if (zerop (call-process-region (point-min) (point-max) "diff"
nil patchbuf nil "-n" "-" tmpfile))
(message "Buffer is already gofmted")
- [nongnu] elpa/go-mode b78582a 262/495: Rename go-goto-type-signature to go-goto-method-receiver, (continued)
- [nongnu] elpa/go-mode b78582a 262/495: Rename go-goto-type-signature to go-goto-method-receiver, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode a16e2e0 266/495: Update docstring and comments for go--in-function-p, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 94ffc7a 270/495: go-goto-docstring: insert function name even if empty comment, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 093a492 274/495: Rename go--in-function-p to go--below-anonymous-function, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 2f302d2 279/495: Update go--goto-opening-curly-brace to handle more cases, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 29f3380 280/495: Remove trailing whitespace in go-mode.el, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode dd46d4f 281/495: Modify go--goto-opening-curly-brace to use end-of-defun, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 6fc1f35 282/495: Move go-goto keymap to the rest of the keymap, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 400d2ae 289/495: Add a changelog, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 0f9b5c5 291/495: Add go-packages-function and go-packages-go-list, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 8c884f3 292/495: Support goimports' new -srcdir flag,
ELPA Syncer <=
- [nongnu] elpa/go-mode c65dd39 297/495: Complain about outdated goimports, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 0b5b29d 316/495: Reformat code, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode a6717a1 318/495: Fix filename replacement in gofmt error buffer, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 50bceae 326/495: Use HTTPS with go-play-region, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 49521d5 310/495: Add go-reset-gopath, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode b767500 325/495: Set compilation-error-screen-columns to nil, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 15ea9a4 320/495: No longer provide a default in M-x godoc, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 22cbf11 321/495: Support unsaved buffers with gogetdoc, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode 0b25cb5 327/495: Generate HTTPS URL for playground entry, ELPA Syncer, 2021/08/07
- [nongnu] elpa/go-mode f63d982 323/495: Make godoc interactive again, ELPA Syncer, 2021/08/07