Problems with vim-go and vimrc

652 Views Asked by At

I recently installed vim-go from github via this command:

git clone https://github.com/fatih/vim-go.git ~/.vim/pack/plugins/start/vim-go

and it all worked.

But I want to see the line numbers and do some stuff in the "global" vimrc file.

So I added ~/.vim/vimrc and the options also work.

But now I can't use commands like :GoRun anymore ("No command"). If I remove the vimrc, it works again...

1

There are 1 best solutions below

0
On

Recent versions of Vim source a script at startup when you don't have a vimrc so that new or casual users get a slightly richer out-of-the-box experience. This is a laudable idea on paper but it broke a lot of things and caused the very issue you are having for a lot of people.

Case in point, filetype-specific plugins like vim-go rely on filetype detection being enabled. This is done by the script I mentioned above but you are on your own when you decide to create your own vimrc: the script in question is not sourced, so filetype detection is disabled by default, so filetype-specific plugins like vim-go don't work.

You can handle the situation in two ways:

  1. source that script from your vimrc, as mentioned in :help defaults.vim:

    unlet! skip_defaults_vim
    source $VIMRUNTIME/defaults.vim
    
  2. take full control of your config by adding what you need to your vimrc, as you need it:

    filetype plugin indent on
    

I would go with the second solution.