Vim-go: `g:go_metalinter_command` does not override the command.

Created on 19 Dec 2017  ·  6Comments  ·  Source: fatih/vim-go

What did you do? (required. The issue will be closed when not provided.)

Wrote let g:go_metalinter_command = "gometalinter --config=" . $HOME . "/.gometalinter/config.json"

What did you expect to happen?

gometalinter called with an argument, --config=$HOME/.gometalinter/config.json

What happened instead?

gometalinter called with arguments, --disable-all gometalinter --config=$HOME/.gometalinter/config.json

Configuration (MUST fill this out):

  • Vim version (first two lines from :version):
:version
VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Dec 17 2017 21:40:26)
macOS version
適用済パッチ: 1-1350
Compiled by Homebrew
Huge 版 without GUI.  機能の一覧 有効(+)/無効(-)
+acl               +cryptv            -footer            +mksession         +path_extra        +syntax            +viminfo
+arabic            +cscope            +fork()            +modify_fname      +perl              +tag_binary        +vreplace
+autocmd           +cursorbind        +gettext           +mouse             +persistent_undo   +tag_old_static    +wildignore
-autoservername    +cursorshape       -hangul_input      -mouseshape        +postscript        -tag_any_white     +wildmenu
-balloon_eval      +dialog_con        +iconv             +mouse_dec         +printer           +tcl               +windows
+balloon_eval_term +diff              +insert_expand     -mouse_gpm         +profile           +termguicolors     +writebackup
-browse            +digraphs          +job               -mouse_jsbterm     -python            +terminal          -X11
++builtin_terms    -dnd               +jumplist          +mouse_netterm     +python3           +terminfo          -xfontset
+byte_offset       -ebcdic            +keymap            +mouse_sgr         +quickfix          +termresponse      -xim
+channel           +emacs_tags        +lambda            -mouse_sysmouse    +reltime           +textobjects       -xpm
+cindent           +eval              +langmap           +mouse_urxvt       +rightleft         +timers            -xsmp
-clientserver      +ex_extra          +libcall           +mouse_xterm       +ruby              +title             -xterm_clipboard
+clipboard         +extra_search      +linebreak         +multi_byte        +scrollbind        -toolbar           -xterm_save
+cmdline_compl     +farsi             +lispindent        +multi_lang        +signs             +user_commands
+cmdline_hist      +file_in_path      +listcmds          -mzscheme          +smartindent       +vertsplit
+cmdline_info      +find_in_path      +localmap          +netbeans_intg     +startuptime       +virtualedit
+comments          +float             +lua               +num64             +statusline        +visual
+conceal           +folding           +menu              +packages          -sun_workshop      +visualextra
      システム vimrc: "$VIM/vimrc"
      ユーザー vimrc: "$HOME/.vimrc"
   第2ユーザー vimrc: "~/.vim/vimrc"
       ユーザー exrc: "$HOME/.exrc"
  デフォルトファイル: "$VIMRUNTIME/defaults.vim"
       省略時の $VIM: "/usr/local/share/vim"
コンパイル: clang -c -I. -Iproto -DHAVE_CONFIG_H   -DMACOS_X -DMACOS_X_DARWIN  -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
リンク: clang   -L. -L/Users/yamada/.rbenv/versions/2.4.2/lib  -fstack-protector -L/usr/local/lib  -L/usr/local/lib -o vim        -lm  -
lncurses -liconv -lintl -framework AppKit  -L/usr/local/lib -llua -fstack-protector  -L/System/Library/Perl/5.18/darwin-thread-multi-2le
vel/CORE -lperl  -L/usr/local/opt/python3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/config-3.6m-darwin -lpython3.6m -framew
ork CoreFoundation -F/System/Library/Frameworks -framework Tcl -framework CoreFoundation -lruby-static -framework CoreFoundation -lgmp -
lobjc -L/Users/yamada/.rbenv/versions/2.4.2/lib
  • Go version (go version):
go version go1.9.2 darwin/amd64
  • Go environment (go env):
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/yamada/go"
GORACE=""
GOROOT="/usr/local/Cellar/go/1.9.2/libexec"
GOTOOLDIR="/usr/local/Cellar/go/1.9.2/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/1z/271lqzy54m51c2y_bjt5n4h00000gn/T/go-build120480347=/tmp/go-build -gno-record-gcc-switches -fno-common"
CXX="clang++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
  • vim-go version:

commit: f4b4ba13f95883cbb4f7c43b871a480932614e0f

  • vimrc you used to reproduce (use a minimal vimrc with other plugins disabled; do not link to a 2,000 line vimrc):
let g:go_metalinter_command = "gometalinter --config=" . $HOME . "/.gometalinter/config.json"

Most helpful comment

I saw the function go#lint#Gometa, but it's ... confused...

  • goargs is not used anywhere.
  • ["--disable-all"] is pushed for args constantly.
  • Some variables named autosave but they seem to be on_save.
  • [--include='^%:p.*$'] is pushed for args only if the async mode is disabled.
  • On save, go_metalinter_command is never used.

It needs to be refactored.

All 6 comments

I can duplicate this.

As far as i see in code g:go_metalinter_deadline is used like g:go_metalinter_aditional_args.
Change this to @kyoh86 expected behavior is easy but will not work with autosave nicly.

For me bether solution is to change this to go:go_metalinter_aditional_args. Additionaly autosave should use it.

I don't stick to replacing a command.
g:go_metalinter_aditional_args is better, I think so.

For your reference, ALE has some options for gometalinter like below.

let g:ale_go_gometalinter_options = "--config=" . $HOME . "/.gometalinter/config.json"
let g:ale_go_gometalinter_executable = 'gometalinter'

I saw the function go#lint#Gometa, but it's ... confused...

  • goargs is not used anywhere.
  • ["--disable-all"] is pushed for args constantly.
  • Some variables named autosave but they seem to be on_save.
  • [--include='^%:p.*$'] is pushed for args only if the async mode is disabled.
  • On save, go_metalinter_command is never used.

It needs to be refactored.

@kyoh86 some of the issues you noticed are resolved in #1640.

For the others:

  • --disable-all is used so that only the enabled linters will apply.
  • autosave is the name of the function argument that indicates whether the function has been called because running gometalinter on save is turned on.
  • the additional arguments to pass to gometalinter from g:go_metalinter_command is applied in all cases except for when running gometalinter automatically on save: https://github.com/fatih/vim-go/blob/master/autoload/go/lint.vim#L62

except for when running gometalinter automatically on save

i know...but why is the case excepted?

It's not clear to me if that was an intentional decision or not. The docs, though, say that g:go_metalinter_command only applies when :GoMetaLinter is called. I plan to revisit whether it should always apply soon.

Was this page helpful?
0 / 5 - 0 ratings