Browse files

Add go syntax highlighting

  • Loading branch information...
1 parent 571f60a commit 8a9991f7b8de39129500c7346270f12b3f75195e @gabebw committed Feb 2, 2013
Showing with 123 additions and 0 deletions.
  1. +3 −0 .gitignore
  2. +2 −0 vim/autocommand.vim
  3. +5 −0 vim/bundle/go.vim/README
  4. +112 −0 vim/bundle/go.vim/syntax/go.vim
  5. +1 −0 vim/vundle.vim
@@ -16,3 +16,6 @@ vim/undodir
+# Vundle stuff
@@ -19,6 +19,8 @@ augroup myfiletypes
au BufRead,BufNewFile *.coffee set syntax=coffee
+ au BufRead,BufNewFile *.go setf go
" .gitconfig and gitconfig are the same
au BufRead,BufNewFile gitconfig set syntax=gitconfig
@@ -0,0 +1,5 @@
+This is a mirror of
+Syntax file for the Go programming language.
+NOTE: There is already a syntax file in the go repository. You can find it under $GOROOT/misc/vim/go.vim
@@ -0,0 +1,112 @@
+" Vim syntax file
+" Language: Go
+" Maintainer: David Daub <>
+" Last Change: 2009 Nov 15
+" Version: 0.1
+" Early version. Took some (ok, most) stuff from existing syntax files like
+" c.vim or d.vim.
+" Todo:
+" - very much
+" Quit when a (custom) syntax file was already loaded
+if exists("b:current_syntax")
+ finish
+" A bunch of useful Go keywords
+syn keyword goStatement select
+syn keyword goStatement defer
+syn keyword goStatement fallthrough range type
+syn keyword goStatement return
+syn keyword goClause import package
+syn keyword goConditional if else switch
+syn keyword goBranch goto break continue
+syn keyword goLabel case default
+syn keyword goRepeat for
+syn keyword goType struct const interface func
+syn keyword goType var map
+syn keyword goType uint8 uint16 uint32 uint64
+syn keyword goType int8 int16 int32 int64
+syn keyword goType float32 float64
+syn keyword goType float32 float64
+syn keyword goType byte
+syn keyword goType uint int float uintptr string
+syn keyword goConcurrent chan go
+syn keyword goValue nil
+syn keyword goBoolean true false
+syn keyword goConstant iota
+" Builtin functions
+syn keyword goBif len make new close closed cap map
+" According to the language specification it is not garanteed to stay in the
+" language. See
+syn keyword goBif print println panic panicln
+" Commants
+syn keyword goTodo contained TODO FIXME XXX
+syn match goLineComment "\/\/.*" contains=@Spell,goTodo
+syn match goCommentSkip "^[ \t]*\*\($\|[ \t]\+\)"
+syn region goComment start="/\*" end="\*/" contains=@Spell,goTodo
+" Numerals
+syn case ignore
+"integer number, or floating point number without a dot and with "f".
+syn match goNumbers display transparent "\<\d\|\.\d" contains=goNumber,goFloat,goOctError,goOct
+syn match goNumbersCom display contained transparent "\<\d\|\.\d" contains=goNumber,goFloat,goOct
+syn match goNumber display contained "\d\+\(u\=l\{0,2}\|ll\=u\)\>"
+" hex number
+syn match goNumber display contained "0x\x\+\(u\=l\{0,2}\|ll\=u\)\>"
+" oct number
+syn match goOct display contained "0\o\+\(u\=l\{0,2}\|ll\=u\)\>" contains=goOctZero
+syn match goOctZero display contained "\<0"
+syn match goFloat display contained "\d\+\.\d*\(e[-+]\=\d\+\)\="
+syn match goFloat display contained "\d\+e[-+]\=\d\=\>"
+syn match goFloat display "\(\.[0-9_]\+\)\(e[-+]\=[0-9_]\+\)\=[fl]\=i\=\>"
+" Literals
+syn region goString start=+L\="+ skip=+\\\\\|\\"+ end=+"+ contains=@Spell
+syn match goSpecial display contained "\\\(x\x\+\|\o\{1,3}\|.\|$\)"
+syn match goCharacter "L\='[^\\]'"
+syn match goCharacter "L'[^']*'" contains=goSpecial
+hi def link goStatement Statement
+hi def link goClause Preproc
+hi def link goConditional Conditional
+hi def link goBranch Conditional
+hi def link goLabel Label
+hi def link goRepeat Repeat
+hi def link goType Type
+hi def link goConcurrent Statement
+hi def link goValue Constant
+hi def link goBoolean Boolean
+hi def link goConstant Constant
+hi def link goBif Function
+hi def link goTodo Todo
+hi def link goLineComment goComment
+hi def link goComment Comment
+hi def link goNumbers Number
+hi def link goNumbersCom Number
+hi def link goNumber Number
+hi def link goFloat Float
+hi def link goOct Number
+hi def link goOctZero Number
+hi def link goString String
+hi def link goSpecial Special
+hi def link goCharacter Character
+let b:current_syntax = "go"
@@ -25,6 +25,7 @@ Bundle 'endwise.vim'
Bundle 'rake.vim'
Bundle 'kien/ctrlp.vim'
Bundle 'vim-coffee-script'
+Bundle 'go.vim'
" Colorschemes
Bundle 'nanotech/jellybeans.vim'

0 comments on commit 8a9991f

Please sign in to comment.