This is a follow-up to #1244, which I found while trying to answer this question for myself.
I'd like to pass the --blank and --ignoretests flags to errcheck when using :GoMetalinter.
I can pass arguments to errcheck from the command line using this GoMetalinter command:
gometalinter --linter='errcheck:errcheck --blank --ignoretests {path}:PATH:LINE:MESSAGE' --disable-all --enable=errcheck .
I can also get this behavior to happen by directly setting g:go_metalinter_command, but this prevents me from having different autosave and manual linter lists for the metalinter. I'd love a feature that lets me define the a custom linter definition for GoMetalinter to be used when that linter is enabled, as I'm doing with the command-line above.
If I understand you correctly you want to have the :GoMetalinter command to run gometalinter with different flags than the gometalinter command that's run when you have g:go_metalinter_autosave enabled?
Yes. If I set g:go_metalinter_command, I lose the ability to have different metalinter settings for g:go_metalinter_autosave_enabled and :GoMetalinter.
I'd like to be able to set commands or add flags for individual linters - something like:
let g:go_metalinter_enabled = ['vet', 'errcheck --blank --lint', 'golint']
let g:go_metalinter_autosave_enabled = ['vet']
You can accomplish this by using autocommands to change g:go_metalinter_enabled before the buffer is written and change it back after it's been written (you'll need to make sure that the autocommands are configured to run in the right order respective to vim-go's autocommands, though).
Something like autocmd BufWritePre <buffer> let g:go_metalinter_enabled = ['vet'] in $VIM/ftplugin/go.vim and autocmd BufWritePost <buffer> let g:go_metalinter_enabled = ['vet', 'errcheck --blank --lint', 'golint'] in $VIM/after/ftplugin/go.vim should work.
Most helpful comment
Yes. If I set
g:go_metalinter_command, I lose the ability to have different metalinter settings forg:go_metalinter_autosave_enabledand:GoMetalinter.I'd like to be able to set commands or add flags for individual linters - something like: