Skip to content

Commit

Permalink
add more syntax to go.vim although i cant get it to work, fix go-link
Browse files Browse the repository at this point in the history
  • Loading branch information
jmoiron committed May 17, 2014
1 parent ff170f1 commit 0ac68d3
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 4 deletions.
4 changes: 2 additions & 2 deletions home/.bash_aliases
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ fi
alias t="t --task-dir ~/tasks --list tasks"

function go-link {
version=`gvm list |grep '=>' |cut -d' ' -f 2`
version=`go version |cut -d" " -f 3`
name=`basename $1`
dirpath=`dirname $1`/$name
pkg_path="$HOME/.gvm/pkgsets/go$version/global/src/github.com/jmoiron"
pkg_path="$HOME/.gvm/pkgsets/$version/global/src/github.com/jmoiron"
mkdir -p $pkg_path
if [ -d "$pkg_path/$name" ]; then
rm -rf $pkg_path/$name
Expand Down
73 changes: 71 additions & 2 deletions home/.vim/syntax/go.vim
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,39 @@ endif
if !exists("go_highlight_array_whitespace_error")
let go_highlight_array_whitespace_error = 1
endif

if !exists("go_highlight_chan_whitespace_error")
let go_highlight_chan_whitespace_error = 1
endif

if !exists("go_highlight_extra_types")
let go_highlight_extra_types = 1
endif

if !exists("go_highlight_space_tab_error")
let go_highlight_space_tab_error = 1
endif

if !exists("go_highlight_trailing_whitespace_error")
let go_highlight_trailing_whitespace_error = 1
endif

if !exists("go_highlight_operators")
let go_highlight_operators = 1
endif

if !exists("go_highlight_functions")
let go_highlight_functions = 1
endif

if !exists("go_highlight_methods")
let go_highlight_methods = 1
endif

if !exists("go_highlight_structs")
let go_highlight_structs = 1
endif

syn case match

syn keyword goDirective package import
Expand Down Expand Up @@ -81,8 +101,8 @@ hi def link goComplexes Type

" Treat func specially: it's a declaration at the start of a line, but a type
" elsewhere. Order matters here.
syn match goType /\<func\>/
syn match goDeclaration /^func\>/
syn match goDeclaration /\<func\>/


" Predefined functions and values
syn keyword goBuiltins append cap close complex copy delete imag len
Expand Down Expand Up @@ -197,6 +217,55 @@ endif
hi def link goExtraType Type
hi def link goSpaceError Error



" included from: https://github.com/athom/more-colorful.vim/blob/master/after/syntax/go.vim
"
" Comments; their contents
syn keyword goTodo contained NOTE
hi def link goTodo Todo


" Operators;
if go_highlight_operators != 0
syn match goOperator /:=/
syn match goOperator />=/
syn match goOperator /<=/
syn match goOperator /==/
syn match goOperator /!=/
syn match goOperator /+=/
syn match goOperator /-=/
syn match goOperator /\s>\s/
syn match goOperator /\s<\s/
syn match goOperator /\s+\s/
syn match goOperator /\s-\s/
syn match goOperator /\s\*\s/
syn match goOperator /\s\/\s/
syn match goOperator /\s%\s/
endif
hi def link goOperator Operator

" Functions;
if go_highlight_functions != 0
syn match goFunction /\%#=1\(func\s\+\)\@<=\w\+\((\)\@=/
syn match goFunction /\%#=1\()\s\+\)\@<=\w\+\((\)\@=/
endif
hi def link goFunction Function

" Methods;
if go_highlight_methods != 0
syn match goMethod /\%#=1\(\.\)\@<=\w\+\((\)\@=/
endif
hi def link goMethod Type

" Structs;
if go_highlight_structs != 0
syn match goStruct /\%#=1\(.\)\@<=\w\+\({\)\@=/
syn match goStructDef /\%#=1\(type\s\+\)\@<=\w\+\(\s\+struct\s\+{\)\@=/
endif
hi def link goStruct Function
hi def link goStructDef Function

" Search backwards for a global declaration to start processing the syntax.
"syn sync match goSync grouphere NONE /^\(const\|var\|type\|func\)\>/

Expand Down

0 comments on commit 0ac68d3

Please sign in to comment.