Created
January 14, 2016 20:57
-
-
Save termie/34326bd29e89565c95fa to your computer and use it in GitHub Desktop.
patch to allow vim-go to use new vendor feature in go imports
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let g:go_fmt_command = "goimports" | |
let g:go_fmt_options = "-f " . expand("%:p") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/cmd/goimports/goimports.go b/cmd/goimports/goimports.go | |
index b0b7aa8..1085f5a 100644 | |
--- a/cmd/goimports/goimports.go | |
+++ b/cmd/goimports/goimports.go | |
@@ -22,9 +22,10 @@ import ( | |
var ( | |
// main operation modes | |
- list = flag.Bool("l", false, "list files whose formatting differs from goimport's") | |
- write = flag.Bool("w", false, "write result to (source) file instead of stdout") | |
- doDiff = flag.Bool("d", false, "display diffs instead of rewriting files") | |
+ list = flag.Bool("l", false, "list files whose formatting differs from goimport's") | |
+ write = flag.Bool("w", false, "write result to (source) file instead of stdout") | |
+ doDiff = flag.Bool("d", false, "display diffs instead of rewriting files") | |
+ useFile = flag.String("f", "", "real filename if using temp file") | |
options = &imports.Options{ | |
TabWidth: 8, | |
@@ -78,7 +79,12 @@ func processFile(filename string, in io.Reader, out io.Writer, stdin bool) error | |
return err | |
} | |
- res, err := imports.Process(filename, src, opt) | |
+ useFilename := filename | |
+ if *useFile != "" { | |
+ useFilename = *useFile | |
+ } | |
+ | |
+ res, err := imports.Process(useFilename, src, opt) | |
if err != nil { | |
return err | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment