From d801ac8b9d8893d9699e8e24473e65dacceec875 Mon Sep 17 00:00:00 2001 From: Knut Ahlers Date: Wed, 17 Oct 2018 00:23:25 +0200 Subject: [PATCH] Use a wrapper for goimports and gofmt Signed-off-by: Knut Ahlers --- bin/gofmtimport | 10 ++++++++++ vimrc | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100755 bin/gofmtimport diff --git a/bin/gofmtimport b/bin/gofmtimport new file mode 100755 index 0000000..9c92f60 --- /dev/null +++ b/bin/gofmtimport @@ -0,0 +1,10 @@ +#!/bin/bash +set -euxo pipefail + +[ ${DEBUG:-0} -eq 1 ] && exec 2>/tmp/gofmtimport.dbg + +goimports \ + -srcdir "$2" \ + -local "${GOIMPORT_LOCAL:-}" \ + -w "$2" +gofmt -s -w "$2" diff --git a/vimrc b/vimrc index 3fb22df..7d98d86 100644 --- a/vimrc +++ b/vimrc @@ -961,7 +961,7 @@ hi SignColumn cterm=none ctermbg=none " " Use goimports for Fmt " -let g:go_fmt_command = "goimports" +let g:go_fmt_command = expand("~/.vim/bin/gofmtimport") " " filetype (common for plugins)