简体   繁体   中英

GoLang Highlighting in vim not working

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.

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM