0

I've seen multiple places(including here) that to add syntax highlighting you have to add certain lines to the .vimrc:

"Stuff for GoLang"
filetype off
filetype plugin indent off
set runtimepath+=$GOROOT/misc/vim
filetype plugin indent on
syntax on

That is what's currently in my .vimrc
Restarted vim, terminal, system, and still no highlighting. Any suggestions?

Okay guys, I go the answer:

$GOROOT needs to be defined or you can simply put the location of your go installation.

Community
  • 1
  • 1
Awalrod
  • 268
  • 1
  • 4
  • 14
  • do you have GOROOT environment variable defined? Try running "echo $GOROOT" in a shell. – kostya Apr 01 '14 at 02:09
  • Output nothing @kostya – Awalrod Apr 01 '14 at 02:10
  • But the `$GOROOT` is only for go installations not in `/usr/local` right? @kostya – Awalrod Apr 01 '14 at 02:13
  • 1
    if GOROOT is not defined then the following line from your .vimrc "set runtimepath+=$GOROOT/misc/vim" cannot find a directory with plugin. – kostya Apr 01 '14 at 02:15
  • Try to find where $GOROOT/misc/vim is installed on your PC and if it is not there just download go sources and unpack it somewhere. Then modify the runtimepath line to point to the right location. – kostya Apr 01 '14 at 02:20

1 Answers1

0

Ensure that the corresponding runtime files are actually there.

  1. $GOROOT must be defined; check with :echo $GOROOT
  2. There must a syntax plugin (syntax/go.vim) below $GOROOT/misc/vim. Check with :echo filereadable($GOROOT . '/misc/vim/syntax/go.vim').
  3. After opening a Go file, you can check again via :scriptnames and :syntax list.
Ingo Karkat
  • 167,457
  • 16
  • 250
  • 324