I've been trying to get vim-go to work for a while. I could always get the :GoInstallBinaries, :GoPath and :GoUpdateBinaries commands to work, but all the other features weren't working.
I tried reducing the problem as much as I could, but it seems that merely having ~/.vimrc in my user profile is enough to break vim-go on my system. I removed literally everything else in my .vim directory, but having a .vimrc of 0 bytes is enough to break vim-go
Please create a reproducible case of your problem. If this step is
not provided, the issue will be closed
Re produce it with a minimal vimrc with all plugins disabled and
only vim-go enabled:
rm -rf ~/.vimrc ~/.vim &&
git clone https://github.com/fatih/vim-go.git ~/.vim/pack/plugins/start/vim-go:GoBuild -- notice it workstouch ~/.vimrc:GoBuild and see E492: Not an editor command: GoBuildAdd here your current configuration and additional information that might be
useful, such as:
vimrc you used to reproduce -- the issue is that a .vimrc of 0 bytes triggers the issue. Existence of this file is enoughmacvim: stable 8.0-138 (bottled), HEAD
VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Oct 5 2017 04:42:50)
MacOS X (unix) version
Included patches: 1-1175
Compiled by [email protected]
master and v1.15go version go1.8.3 darwin/amd64When there is no vimrc, Vim will load $VIMRUNTIME/defaults.vim, which sets some more modern defaults. But when there's a vimrc present (empty or otherwise) it will use the old vi-compatible settings. Specifically, filetype detection won't be enabled. Adding filetype plugin indent on should fix that.
It's kinda confusing how this works :-/ See :help defaults.vim for more info.
Yep, that fixes it. Maybe a line in the README.md saying "If you have a .vimrc file, ensure it has filetype plugin indent on".
It's more of a general Vim caveat, lots of stuff will break if you add an empty ~/.vimrc file, not just vim-go. Frankly, this feature is not very well thought out IMHO, and it seems I'm not the only one who thinks so.
Agreed that it's a general vim caveat, but that makes it even more useful to highlight the strange behaviour. It might be worth mentioning on the README.md a quick one line note.
@Carpetsmoker I agree with @jhford, it is worth adding the one line - a lot of people are going to get bitten by this.
Most helpful comment
When there is no vimrc, Vim will load
$VIMRUNTIME/defaults.vim, which sets some more modern defaults. But when there's a vimrc present (empty or otherwise) it will use the old vi-compatible settings. Specifically, filetype detection won't be enabled. Addingfiletype plugin indent onshould fix that.It's kinda confusing how this works :-/ See
:help defaults.vimfor more info.