Vim-go: having a .vimrc file in my home directory causes vim-go to not load

Created on 12 Oct 2017  路  5Comments  路  Source: fatih/vim-go

Behavior

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

Steps to reproduce:

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:

  1. rm -rf ~/.vimrc ~/.vim && git clone https://github.com/fatih/vim-go.git ~/.vim/pack/plugins/start/vim-go
  2. Launch vim
  3. run :GoBuild -- notice it works
  4. touch ~/.vimrc
  5. launch vim
    22: run :GoBuild and see E492: Not an editor command: GoBuild

Configuration

Add 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 enough
  • vim version:
macvim: 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]
  • vim-go version: checked out master and v1.15
  • go version: go version go1.8.3 darwin/amd64

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. Adding filetype plugin indent on should fix that.

It's kinda confusing how this works :-/ See :help defaults.vim for more info.

All 5 comments

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. 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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

andrejvanderzee picture andrejvanderzee  路  3Comments

groob picture groob  路  3Comments

korjavin picture korjavin  路  4Comments

Michael-F-Ellis picture Michael-F-Ellis  路  3Comments

zhangjing picture zhangjing  路  3Comments